Documentation
¶
Overview ¶
Package tokentracker scans local machine files left behind by LLM CLIs and desktop apps (Claude Code, Codex, ChatGPT, Gemini, ...) and reports how many tokens they've used, broken down by provider and by token type.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Provider Provider
Model string
Time time.Time
Usage TokenUsage
Source string // path to the file this entry was read from
}
Entry is a single usage record read from a provider's local log/history file.
type Report ¶
type Report struct {
Entries []Entry
ByProvider map[Provider]TokenUsage
ByTokenType TokenUsage
}
Report aggregates token usage across all detected providers.
func Scan ¶
Scan walks every registered provider's local usage files and returns the combined report, covering every entry ever recorded (not just one day). A provider failing to scan does not stop the others; their errors are joined and returned alongside whatever entries were recovered. Use Report.Day or Report.Filter to narrow the result down to a specific date.
func (Report) ByDay ¶
ByDay buckets every entry into a Report per calendar day, keyed by "2006-01-02" using loc for day boundaries. Pass time.Local to bucket by your machine's local days, or time.UTC to match raw timestamps.
func (Report) Day ¶
Day returns a Report scoped to entries whose timestamp falls on the same calendar day as t, using t's own location to decide day boundaries. Pass time.Now() for "today", or a time.Time constructed for the target date (e.g. time.Date(2026, 7, 15, 0, 0, 0, 0, time.Local)).
type TokenType ¶
type TokenType string
TokenType identifies a category of tokens within a single LLM exchange.
type TokenUsage ¶
TokenUsage holds token counts keyed by TokenType.
func (TokenUsage) Add ¶
func (u TokenUsage) Add(other TokenUsage) TokenUsage
Add returns a new TokenUsage with u and other's counts summed per type. Either receiver may be nil.
func (TokenUsage) Total ¶
func (u TokenUsage) Total() int64
Total returns the sum of all token counts in u.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
tokentracker
command
Command tokentracker prints a table of local LLM token usage, for manually exercising the tokentracker package.
|
Command tokentracker prints a table of local LLM token usage, for manually exercising the tokentracker package. |