internal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OutputDailyJSON

func OutputDailyJSON(summaries []DailySummary) error

OutputDailyJSON prints daily summaries as JSON

func OutputDailyTable

func OutputDailyTable(summaries []DailySummary)

OutputDailyTable prints daily summaries in a table format

func OutputSessionJSON

func OutputSessionJSON(summaries []SessionSummary) error

OutputSessionJSON prints session summaries as JSON

func OutputSessionTable

func OutputSessionTable(summaries []SessionSummary)

OutputSessionTable prints session summaries in a table format

Types

type DailySummary

type DailySummary struct {
	Date              string
	InputTokens       int
	OutputTokens      int
	CacheCreateTokens int
	CacheReadTokens   int
	TotalTokens       int
	TotalCost         float64
}

DailySummary aggregates usage data by day

func AggregateDailyUsage

func AggregateDailyUsage(records []UsageRecord) []DailySummary

AggregateDailyUsage groups usage records by day

type JSONLEntry

type JSONLEntry struct {
	Type      string   `json:"type"`
	Timestamp string   `json:"timestamp"`
	CostUSD   float64  `json:"costUSD"`
	Message   *Message `json:"message"`
}

JSONLEntry represents the structure of each JSONL line

type Message

type Message struct {
	Usage *Usage `json:"usage"`
}

Message contains the usage information

type SessionSummary

type SessionSummary struct {
	Project           string
	Session           string
	InputTokens       int
	OutputTokens      int
	CacheCreateTokens int
	CacheReadTokens   int
	TotalTokens       int
	TotalCost         float64
	LastActivity      time.Time
}

SessionSummary aggregates usage data by project/session

func AggregateSessionUsage

func AggregateSessionUsage(records []UsageRecord) []SessionSummary

AggregateSessionUsage groups usage records by project/session

type Usage

type Usage struct {
	InputTokens         int `json:"input_tokens"`
	OutputTokens        int `json:"output_tokens"`
	CacheCreationTokens int `json:"cache_creation_input_tokens"`
	CacheReadTokens     int `json:"cache_read_input_tokens"`
}

Usage represents token usage information

type UsageRecord

type UsageRecord struct {
	Timestamp         time.Time
	Project           string
	Session           string
	InputTokens       int
	OutputTokens      int
	CacheCreateTokens int
	CacheReadTokens   int
	CostUSD           float64
}

UsageRecord represents a single usage entry from JSONL files

func FilterRecordsByDate

func FilterRecordsByDate(records []UsageRecord, since, until time.Time) []UsageRecord

FilterRecordsByDate filters records based on since/until dates

func LoadUsageRecords

func LoadUsageRecords(dataPath string, since, until time.Time) ([]UsageRecord, error)

LoadUsageRecords loads all usage records from JSONL files in the specified directory

Jump to

Keyboard shortcuts

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