Documentation
¶
Overview ¶
Package contextsize measures how large an agent's conversation context is from the usage numbers its launcher writes locally (hadron-cli#2063, the client half of hadron-server#4238 S4a).
It is deliberately narrow, like internal/modelreport:
- Only numbers and a timestamp are decoded. Every record is unmarshalled into a struct that has no field for message content, so transcript text is never held, returned, logged or sent.
- Any doubt returns nil: a missing, unreadable, oversized, unattributable or implausible record yields NO measurement, never a zero.
- A file is attributed to a worker only when the file itself records the worker's worktree as its cwd; a directory-name match alone is not proof.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Measurement ¶
Measurement is one context-size reading: both fields are always set together.
func ClaudeFromFile ¶
func ClaudeFromFile(path, worktree string, now time.Time) (*Measurement, bool)
ClaudeFromFile reads the latest main-thread assistant usage record of a Claude Code transcript whose own cwd is worktree. Context is input + cache-read + cache-creation input tokens of that turn.
func CodexFromFile ¶
func CodexFromFile(path string, now time.Time) (*Measurement, bool)
CodexFromFile reads the latest token_count event of a Codex rollout. The context is the last turn's input tokens (Codex counts cached input inside input_tokens), not the running total, which only grows.
type Roots ¶
type Roots struct {
ClaudeProjects string // e.g. ~/.claude/projects
CodexSessions string // e.g. ~/.codex/sessions
}
Roots are the directories the supported launchers write sessions under.
func DefaultRoots ¶
func DefaultRoots() Roots
DefaultRoots honours CLAUDE_CONFIG_DIR and CODEX_HOME like the tools do.