Documentation
¶
Overview ¶
Package stats answers the usage statistics pages (/api/stats/*) from this machine's Claude Code and Codex files, as the previous runtime's handlers did: the same answers, the same cache files under the data folder, each transcript read again only once it changes.
Index ¶
- Variables
- type Rewrite
- type Route
- func (rt *Route) Aggregated(r *http.Request) (int, any, http.Header)
- func (rt *Route) CacheStatus(r *http.Request) (int, any, http.Header)
- func (rt *Route) DailyReportGenerate(r *http.Request) (int, any, http.Header)
- func (rt *Route) DailyReportList(r *http.Request) (int, any, http.Header)
- func (rt *Route) Facets(r *http.Request) (int, any, http.Header)
- func (rt *Route) History(r *http.Request) (int, any, http.Header)
- func (rt *Route) Overview(r *http.Request) (int, any, http.Header)
- func (rt *Route) Projects(r *http.Request) (int, any, http.Header)
- func (rt *Route) Routes() map[string]func(*http.Request) (int, any, http.Header)
- func (rt *Route) Sessions(r *http.Request) (int, any, http.Header)
- func (rt *Route) Uptime(r *http.Request) (int, any, http.Header)
Constants ¶
This section is empty.
Variables ¶
var DefaultCwdRewrites = []Rewrite{{"Workspace/github.com/", ""}, {"Documents/", "docs/"}}
DefaultCwdRewrites are the old runtime's: GitHub checkouts under Workspace/ lose the host, Documents/ becomes docs/.
var Shadowable = []string{"aggregated", "cache-status", "facets", "history", "overview", "projects", "sessions", "uptime", "daily-report/list"}
Shadowable are the routes of Routes that only read (a shadow may run them next to the old runtime).
Functions ¶
This section is empty.
Types ¶
type Rewrite ¶
type Rewrite struct{ Prefix, To string }
Rewrite replaces a leading Prefix of a project folder with To.
func ParseCwdRewrites ¶
ParseCwdRewrites reads extra rewrites as "prefix=to" pairs separated by commas (an environment value), after the defaults.
type Route ¶
type Route struct {
// Home is the person's home: the old handlers read ~/.claude and ~/.codex there whatever CLAUDE_CONFIG_DIR or
// CODEX_HOME said, and shortened project folders under it.
Home string
// ClaudeDir and CodexDir default to Home/.claude and Home/.codex.
ClaudeDir, CodexDir string
// DataDir holds stats/cache.json, stats/uptime-cache.json and stats/daily-reports.
DataDir string
// ConfigFile is the runtime's config.json (noteSummaryProvider picks the daily report's CLI).
ConfigFile string
// Authorized is the old dispatcher's check: a page session or the cli-token.
Authorized func(*http.Request) bool
// CwdRewrites shorten a project folder (relative to Home) after the home is cut: each prefix in order, applied to
// what the previous left. The old runtime's own are DefaultCwdRewrites.
CwdRewrites []Rewrite
// ShellPath is the PATH the daily report's CLI runs with (the person's login shell's); nil is this process's.
ShellPath func() string
// CLITimeout bounds the daily report's CLI run (120 s when 0).
CLITimeout time.Duration
// Now is the clock (tests freeze it); nil is the real one.
Now func() time.Time
// contains filtered or unexported fields
}
Route answers the routes under /api/stats/.
func (*Route) Aggregated ¶
Aggregated answers GET /api/stats/aggregated?period=.
func (*Route) CacheStatus ¶
CacheStatus answers GET /api/stats/cache-status.
func (*Route) DailyReportGenerate ¶
DailyReportGenerate answers POST /api/stats/daily-report/generate {date, force?, locale?, provider?}.
func (*Route) DailyReportList ¶
DailyReportList answers GET /api/stats/daily-report/list?offset=&limit=.
func (*Route) Routes ¶
Routes are the answers by the path after /api/stats/. All are idempotent GETs except "daily-report/generate", a POST that runs a CLI and writes the report. daily-report/cache is not here: nothing calls it.