Documentation
¶
Index ¶
- func FormatAge(t time.Time) string
- func FormatTokenCount(n int64) string
- func HasActiveSession(worktreePath string) bool
- func IsProcessRunning(sessionID string) bool
- func SessionFilePath(worktreePath, sessionID string) string
- func ShortenModel(model string) string
- type Session
- type SessionDetail
- type TokenUsage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatTokenCount ¶
FormatTokenCount formats a token count in human-readable form (e.g. 1.2K, 3.5M).
func HasActiveSession ¶
HasActiveSession checks if a worktree has any Claude session files. This is a lightweight check - it doesn't verify if the session is running.
func IsProcessRunning ¶
IsProcessRunning checks if a Claude process is running for the given session ID by looking for a process whose command line contains the session ID.
func SessionFilePath ¶
SessionFilePath returns the full filesystem path for a session .jsonl file.
func ShortenModel ¶
ShortenModel shortens a Claude model identifier. "claude-opus-4-6" -> "opus-4-6", "claude-sonnet-4-5-20250929" -> "sonnet-4-5"
Types ¶
type Session ¶
type Session struct {
ID string `json:"id"`
Modified int64 `json:"modified_epoch"`
ModHuman string `json:"modified"`
Size int64 `json:"size"`
SizeStr string `json:"size_str"`
}
Session represents a Claude Code session file.
func FindSessions ¶
FindSessions finds Claude sessions for a worktree path by scanning ~/.claude/projects/<encoded-path>/*.jsonl files.
type SessionDetail ¶
type SessionDetail struct {
Session
Model string `json:"model"`
Tokens TokenUsage `json:"tokens"`
Running bool `json:"running"`
LastActive time.Time `json:"last_active"`
AgeStr string `json:"age_str"`
}
SessionDetail extends Session with parsed token usage and process status.
type TokenUsage ¶
type TokenUsage struct {
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
CacheCreationInputTokens int64 `json:"cache_creation_input_tokens"`
CacheReadInputTokens int64 `json:"cache_read_input_tokens"`
}
TokenUsage holds aggregated token counts from a session.
func ParseSessionDetailFull ¶
func ParseSessionDetailFull(path string) (model string, tokens TokenUsage, err error)
ParseSessionDetailFull reads the entire session file and sums up all token usage. Slower but accurate for total counts.
func ParseSessionDetailTail ¶
func ParseSessionDetailTail(path string) (model string, tokens TokenUsage, err error)
ParseSessionDetailTail reads the last tailSize bytes of a session file and extracts the model and most recent token usage. This is fast but may not capture all token usage from long sessions.