stats

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package stats keeps an opt-in, local-only usage log. Nothing here touches the network. It records bytes/4 token estimates, never file contents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enabled

func Enabled(root string) bool

Enabled reports whether logging is on: STACKLIT_STATS=1 or "stats": true in .stacklitrc.json. Default off.

func LogPath

func LogPath() string

LogPath is the JSONL file under the user cache dir.

func Record

func Record(root, cmd, output string)

Record appends one entry when logging is enabled. Errors are swallowed: statistics must never break a command.

func ReplacedEstimate

func ReplacedEstimate(root, text string) (tokens, files int)

ReplacedEstimate sums the sizes of existing files under root that text mentions by path, as tokens, and returns how many files matched.

func Tokens

func Tokens(s string) int

Tokens is the bytes/4 estimate used everywhere in stacklit.

Types

type CmdTotals

type CmdTotals struct {
	Cmd         string `json:"cmd"`
	Calls       int    `json:"calls"`
	Served      int    `json:"served"`
	ReplacedEst int    `json:"replaced_est"`
}

CmdTotals aggregates one command.

type Entry

type Entry struct {
	TS   string `json:"ts"`
	Cmd  string `json:"cmd"`
	Repo string `json:"repo,omitempty"` // base name only, never a full path
	// Served is the estimated tokens of the answer (bytes/4).
	Served int `json:"served"`
	// ReplacedEst estimates the tokens of the whole files the answer pointed
	// into. It is an estimate of what reading them would cost, not a
	// measurement of what the agent would have done.
	ReplacedEst int `json:"replaced_est"`
	Files       int `json:"files"`
}

Entry is one logged call.

type Summary

type Summary struct {
	Since       string      `json:"since,omitempty"`
	Calls       int         `json:"calls"`
	Served      int         `json:"served"`
	ReplacedEst int         `json:"replaced_est"`
	ByCmd       []CmdTotals `json:"by_cmd"`
}

Summary is the report over a time window.

func Read

func Read(since time.Time) (Summary, error)

Read aggregates the log for entries at or after since (zero means all).

Jump to

Keyboard shortcuts

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