codeburn

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package codeburn reads CodeBurn's client-facing menubar JSON through its resident stdio server. CodeBurn remains responsible for discovering agent sessions, normalizing token usage, pricing models, and classifying activity; orchard only consumes and renders the resulting local data.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("codeburn unavailable")

ErrUnavailable means CodeBurn is disabled or its executable is not on PATH.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	Name        string   `json:"name"`
	Cost        float64  `json:"cost"`
	Turns       int      `json:"turns"`
	OneShotRate *float64 `json:"oneShotRate"`
}

type Client

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

Client owns one warm `codeburn serve --stdio` child. Queries are serialized because CodeBurn's resident protocol and aggregation pipeline are serialized.

func NewClient

func NewClient() *Client

NewClient resolves CodeBurn from ORCHARD_CODEBURN or PATH. Set the variable to off/0/false to disable integration, or to an executable path to override.

func NewClientWithExecutable

func NewClientWithExecutable(path string) *Client

NewClientWithExecutable builds a client for an explicit CodeBurn executable.

func (*Client) Available

func (c *Client) Available() bool

Available reports whether the client resolved an executable.

func (*Client) Close

func (c *Client) Close() error

Close stops the resident child. Closing stdin is CodeBurn's documented clean shutdown signal; a short kill fallback prevents orchard exit from hanging.

func (*Client) Query

func (c *Client) Query(ctx context.Context, period Period, root string) (Payload, error)

Query returns a project-root-scoped CodeBurn payload. The resident server is preferred; a one-shot status command is the compatibility fallback.

type CostRow

type CostRow struct {
	Name  string  `json:"name"`
	Calls int     `json:"calls"`
	Turns int     `json:"turns"`
	Cost  float64 `json:"cost"`
}

type CountRow

type CountRow struct {
	Name  string `json:"name"`
	Calls int    `json:"calls"`
}

type Currency

type Currency struct {
	Code   string  `json:"code"`
	Symbol string  `json:"symbol"`
	Rate   float64 `json:"rate"`
}

type Current

type Current struct {
	Label            string             `json:"label"`
	Cost             float64            `json:"cost"`
	EstimatedCostUSD float64            `json:"estimatedCostUSD"`
	Calls            int                `json:"calls"`
	Sessions         int                `json:"sessions"`
	InputTokens      int                `json:"inputTokens"`
	OutputTokens     int                `json:"outputTokens"`
	CacheReadTokens  int                `json:"cacheReadTokens"`
	CacheWriteTokens int                `json:"cacheWriteTokens"`
	CacheHitPercent  float64            `json:"cacheHitPercent"`
	OneShotRate      *float64           `json:"oneShotRate"`
	PricingCoverage  *float64           `json:"pricingCoverage"`
	TopActivities    []Activity         `json:"topActivities"`
	TopModels        []Model            `json:"topModels"`
	TopProjects      []Project          `json:"topProjects"`
	ProviderDetails  []Provider         `json:"providerDetails"`
	Providers        map[string]float64 `json:"providers"`
	Tools            []CountRow         `json:"tools"`
	MCPServers       []CountRow         `json:"mcpServers"`
	Skills           []CostRow          `json:"skills"`
	Subagents        []CostRow          `json:"subagents"`
	UnpricedModels   []UnpricedModel    `json:"unpricedModels"`
	Workflow         Workflow           `json:"workflow"`
}

type Daily

type Daily struct {
	Date             string  `json:"date"`
	Cost             float64 `json:"cost"`
	Calls            int     `json:"calls"`
	InputTokens      int     `json:"inputTokens"`
	OutputTokens     int     `json:"outputTokens"`
	CacheReadTokens  int     `json:"cacheReadTokens"`
	CacheWriteTokens int     `json:"cacheWriteTokens"`
}

type History

type History struct {
	Daily []Daily `json:"daily"`
}

type Model

type Model struct {
	Name             string  `json:"name"`
	Cost             float64 `json:"cost"`
	Calls            int     `json:"calls"`
	EstimatedCostUSD float64 `json:"estimatedCostUSD"`
}

type Payload

type Payload struct {
	Generated string   `json:"generated"`
	Current   Current  `json:"current"`
	History   History  `json:"history"`
	Currency  Currency `json:"currency"`
}

Payload is the stable subset of `codeburn status --format menubar-json` rendered by orchard. Unknown fields are deliberately ignored so additive CodeBurn releases remain compatible.

type Period

type Period string

Period is one of CodeBurn's supported dashboard windows.

const (
	PeriodToday     Period = "today"
	PeriodWeek      Period = "week"
	PeriodThirtyDay Period = "30days"
	PeriodMonth     Period = "month"
	PeriodSixMonths Period = "all"
	PeriodLifetime  Period = "lifetime"
)

func (Period) Label

func (p Period) Label() string

Label returns the compact user-facing name for a period.

type Project

type Project struct {
	Name              string  `json:"name"`
	Cost              float64 `json:"cost"`
	Sessions          int     `json:"sessions"`
	AvgCostPerSession float64 `json:"avgCostPerSession"`
}

type Provider

type Provider struct {
	ID    string  `json:"id"`
	Label string  `json:"label"`
	Cost  float64 `json:"cost"`
}

type UnpricedModel

type UnpricedModel struct {
	Model  string `json:"model"`
	Calls  int    `json:"calls"`
	Tokens int    `json:"tokens"`
}

type Workflow

type Workflow struct {
	Corrections             int      `json:"corrections"`
	CorrectionRate          *float64 `json:"correctionRate"`
	MedianTimeToFirstEditMS *float64 `json:"medianTimeToFirstEditMs"`
}

Jump to

Keyboard shortcuts

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