Documentation
¶
Overview ¶
Package export serializes a stats.Report as JSON, CSV, or Markdown for consumption by scripts, dashboards, or human readers.
Index ¶
- Constants
- func ToCSV(w io.Writer, r stats.Report) error
- func ToJSON(w io.Writer, label string, from, to time.Time, r stats.Report) error
- func ToMarkdown(w io.Writer, label string, r stats.Report) error
- type ByModelCompact
- type CompactPayload
- type ComparisonDeltasDTO
- type ComparisonPayload
- type ComparisonSideDTO
- type CostBreakdownDTO
- type CostBucketDTO
- type DayDTO
- type DeltaDTO
- type ModelBreakdownDTO
- type ModelDTO
- type Payload
- type ProjectDTO
- type RangeDTO
- type SessionDTO
- type SessionDetailDTO
- type SessionTurnDTO
- type ToolEntryDTO
- type ToolsDTO
- type TotalsDTO
Constants ¶
const Schema = "v1"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ByModelCompact ¶ added in v0.3.0
type CompactPayload ¶ added in v0.3.0
type CompactPayload struct {
Range string `json:"range"`
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Prompts int `json:"prompts"`
Turns int `json:"turns"`
Tokens int `json:"tokens"`
Cost float64 `json:"cost_usd"`
TopModel string `json:"top_model,omitempty"`
ByModel []ByModelCompact `json:"by_model,omitempty"`
}
CompactPayload is the shape returned by `claumeter today` / `week` / `range` and the `/today` HTTP endpoint. Keep field names stable — widgets depend on them.
func NewCompact ¶ added in v0.3.0
NewCompact builds a CompactPayload for the given filtered report. `label` is the human-readable range name (e.g. "Today", "This week", "2026-04-01 → 2026-04-17"). `from` / `to` are the [from, to) window; zero values are omitted from the JSON.
type ComparisonDeltasDTO ¶ added in v0.6.0
type ComparisonDeltasDTO struct {
Prompts DeltaDTO `json:"prompts"`
Turns DeltaDTO `json:"turns"`
InputTokens DeltaDTO `json:"input_tokens"`
CacheCreationTokens DeltaDTO `json:"cache_creation_tokens"`
CacheReadTokens DeltaDTO `json:"cache_read_tokens"`
OutputTokens DeltaDTO `json:"output_tokens"`
TotalTokens DeltaDTO `json:"total_tokens"`
CostUSD DeltaDTO `json:"cost_usd"`
}
ComparisonDeltasDTO holds one DeltaDTO per tracked metric.
type ComparisonPayload ¶ added in v0.6.0
type ComparisonPayload struct {
Schema string `json:"schema"`
Generated time.Time `json:"generated"`
A ComparisonSideDTO `json:"a"`
B ComparisonSideDTO `json:"b"`
Deltas ComparisonDeltasDTO `json:"deltas"`
}
ComparisonPayload is the top-level JSON shape returned by NewComparison and the GET /compare endpoint.
func NewComparison ¶ added in v0.6.0
func NewComparison( aLabel string, aFrom, aTo time.Time, aTotals stats.Totals, bLabel string, bFrom, bTo time.Time, bTotals stats.Totals, cmp stats.Comparison, ) ComparisonPayload
NewComparison constructs a ComparisonPayload from two resolved range sides and the Comparison produced by stats.Compare.
type ComparisonSideDTO ¶ added in v0.6.0
type ComparisonSideDTO struct {
Label string `json:"label"`
From time.Time `json:"from,omitempty"`
To time.Time `json:"to,omitempty"`
TotalsDTO
}
ComparisonSideDTO describes one side (A or B) of a comparison.
type CostBreakdownDTO ¶ added in v0.8.2
type CostBreakdownDTO struct {
Overall ModelBreakdownDTO `json:"overall"`
ByModel []ModelBreakdownDTO `json:"by_model"`
TotalCost float64 `json:"total_cost_usd"`
}
CostBreakdownDTO aggregates overall + per-model 5-bucket cost breakdowns.
type CostBucketDTO ¶ added in v0.8.2
type CostBucketDTO struct {
Kind string `json:"kind"`
Tokens int `json:"tokens"`
Rate float64 `json:"rate_usd_per_mtok"`
Cost float64 `json:"cost_usd"`
Pct float64 `json:"pct_of_parent"`
}
CostBucketDTO is one of the 5 priced buckets (input / cache writes / cache read / output) for a model, with its tokens, rate, cost and share of total.
type DeltaDTO ¶ added in v0.6.0
type DeltaDTO struct {
A float64 `json:"a"`
B float64 `json:"b"`
Delta float64 `json:"delta"`
Pct float64 `json:"pct"`
Gt bool `json:"gt"`
}
DeltaDTO is the wire shape for a single metric comparison.
type ModelBreakdownDTO ¶ added in v0.8.2
type ModelBreakdownDTO struct {
Model string `json:"model"`
Buckets []CostBucketDTO `json:"buckets"`
TotalCost float64 `json:"total_cost_usd"`
Pct float64 `json:"pct_of_grand_total"`
}
ModelBreakdownDTO is the 5-bucket breakdown for a single model.
type Payload ¶
type Payload struct {
Schema string `json:"schema"`
Generated time.Time `json:"generated"`
Range RangeDTO `json:"range"`
Overall TotalsDTO `json:"overall"`
ByDay []DayDTO `json:"by_day"`
ByModel []ModelDTO `json:"by_model"`
BySession []SessionDTO `json:"by_session"`
ByProject []ProjectDTO `json:"by_project"`
Tools ToolsDTO `json:"tools"`
CostBreakdown CostBreakdownDTO `json:"cost_breakdown"`
}
Payload is the canonical shape returned by ToJSON. Field names are stable.
type ProjectDTO ¶
type SessionDTO ¶
type SessionDetailDTO ¶ added in v0.6.0
type SessionDetailDTO struct {
SessionID string `json:"session_id"`
Cwd string `json:"cwd"`
FirstSeen time.Time `json:"first_seen"`
LastSeen time.Time `json:"last_seen"`
Models []string `json:"models"`
TotalsDTO // flattened at top level
Turns []SessionTurnDTO `json:"turns"`
}
SessionDetailDTO is the JSON shape returned by GET /session/:id.
func NewSessionDetail ¶ added in v0.6.0
func NewSessionDetail(sd stats.SessionDetail) SessionDetailDTO
NewSessionDetail converts a stats.SessionDetail to its DTO form.
type SessionTurnDTO ¶ added in v0.6.0
type SessionTurnDTO struct {
Timestamp time.Time `json:"timestamp"`
Model string `json:"model"`
TotalsDTO // flattened
Tools []string `json:"tools,omitempty"`
}
SessionTurnDTO is one assistant turn inside a session.
type ToolEntryDTO ¶
type ToolsDTO ¶
type ToolsDTO struct {
Total int `json:"total"`
Builtins []ToolEntryDTO `json:"builtins"`
MCPs []ToolEntryDTO `json:"mcps"`
Servers []ToolEntryDTO `json:"mcp_servers"`
Skills []ToolEntryDTO `json:"skills"`
Agents []ToolEntryDTO `json:"sub_agents"`
}
type TotalsDTO ¶
type TotalsDTO struct {
Prompts int `json:"prompts"`
Turns int `json:"turns"`
InputTokens int `json:"input_tokens"`
CacheCreationTokens int `json:"cache_creation_tokens"`
CacheCreation5mTokens int `json:"cache_creation_5m_tokens"`
CacheCreation1hTokens int `json:"cache_creation_1h_tokens"`
CacheReadTokens int `json:"cache_read_tokens"`
OutputTokens int `json:"output_tokens"`
TotalTokens int `json:"total_tokens"`
CostUSD float64 `json:"cost_usd"`
}