Documentation
¶
Index ¶
- func BuildProcessMap(claudeDir string) map[string]ProcessStatus
- func DiscoverDailyAggregates(claudeDir string) (map[string]SessionAggregate, error)
- func EnrichSessionsWithProcessStatus(sessions []*SessionSummary, claudeDir string, stuckThreshold time.Duration)
- func FindSessionFile(claudeDir, sessionID string) string
- func HourlyTokensToday(claudeDir string) ([24]int, error)
- func KillProcess(claudeDir string, pid int) error
- func KillSession(claudeDir, sessionID string) error
- func ParseSessionFileDaily(path string) (map[string]*SessionAggregate, error)
- func SetPricingTable(t *pricing.Table)
- type PIDInfo
- type ProcessStatus
- type SessionAggregate
- type SessionMessage
- type SessionSummary
- type ToolCall
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildProcessMap ¶ added in v0.6.0
func BuildProcessMap(claudeDir string) map[string]ProcessStatus
BuildProcessMap returns a map from session ID to ProcessStatus for all running sessions.
func DiscoverDailyAggregates ¶ added in v0.9.1
func DiscoverDailyAggregates(claudeDir string) (map[string]SessionAggregate, error)
DiscoverDailyAggregates walks all session files and returns aggregates bucketed by message timestamp (local date). SessionCount on each entry is the number of distinct session files that contributed any message on that date.
func EnrichSessionsWithProcessStatus ¶ added in v0.6.0
func EnrichSessionsWithProcessStatus(sessions []*SessionSummary, claudeDir string, stuckThreshold time.Duration)
EnrichSessionsWithProcessStatus sets IsRunning, IsStuck, PID, and IdleMinutes on each SessionSummary based on live process data.
func FindSessionFile ¶
FindSessionFile finds the JSONL file for a session ID.
func HourlyTokensToday ¶ added in v0.9.1
HourlyTokensToday returns a 24-element slice where index i holds the total tokens (input + output + cache read + cache create) from assistant messages whose timestamp fell in local hour i on the current local day. Messages from other days are skipped, even if they belong to a session that was also active today.
func KillProcess ¶ added in v0.6.0
KillProcess sends an interrupt to a Claude Code process by PID. It verifies the PID belongs to a known Claude session before killing.
func KillSession ¶ added in v0.6.0
KillSession sends an interrupt to the process running a given session.
func ParseSessionFileDaily ¶ added in v0.9.1
func ParseSessionFileDaily(path string) (map[string]*SessionAggregate, error)
ParseSessionFileDaily parses a session JSONL and buckets each assistant message's token usage by its own timestamp's local date. The returned map is keyed by "YYYY-MM-DD". Both user and assistant messages contribute to MessageCount on their own date. SessionCount is left at 0 (set by caller).
func SetPricingTable ¶ added in v0.3.0
SetPricingTable sets the shared pricing table used for cost estimation.
Types ¶
type PIDInfo ¶ added in v0.6.0
type PIDInfo struct {
PID int `json:"pid"`
SessionID string `json:"sessionId"`
CWD string `json:"cwd"`
StartedAt int64 `json:"startedAt"`
Kind string `json:"kind"`
Entrypoint string `json:"entrypoint"`
Title string `json:"title,omitempty"`
Project string `json:"project,omitempty"`
}
PIDInfo represents a running Claude Code session from ~/.claude/sessions/{PID}.json.
func DiscoverPIDFiles ¶ added in v0.6.0
DiscoverPIDFiles reads ~/.claude/sessions/*.json and returns entries with running PIDs.
type ProcessStatus ¶ added in v0.6.0
ProcessStatus holds the live status of a running session process.
type SessionAggregate ¶ added in v0.4.0
type SessionAggregate struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
CacheReadTokens int `json:"cache_read_tokens"`
CacheCreateTokens int `json:"cache_create_tokens"`
CostUSD float64 `json:"cost_usd"`
SessionCount int `json:"session_count"`
MessageCount int `json:"message_count"`
}
SessionAggregate holds aggregated token counts and cost across sessions.
type SessionMessage ¶
type SessionMessage struct {
Type string `json:"type"`
Timestamp time.Time `json:"timestamp"`
Model string `json:"model,omitempty"`
Role string `json:"role"`
Text string `json:"text"`
TokensIn int `json:"tokens_in,omitempty"`
TokensOut int `json:"tokens_out,omitempty"`
CacheRead int `json:"cache_read,omitempty"`
CacheCreate int `json:"cache_create,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
Thinking string `json:"thinking,omitempty"`
}
SessionMessage represents a single parsed message from a session for the detail view.
func ParseSessionDetail ¶
func ParseSessionDetail(path string) ([]SessionMessage, error)
ParseSessionDetail returns the full message timeline for a session.
type SessionSummary ¶
type SessionSummary struct {
ID string `json:"id"`
Project string `json:"project"`
Model string `json:"model"`
Title string `json:"title"`
StartTime time.Time `json:"start_time"`
LastActivity time.Time `json:"last_activity"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
CacheReadTokens int `json:"cache_read_tokens"`
CacheCreateTokens int `json:"cache_create_tokens"`
EstimatedCostUSD float64 `json:"estimated_cost_usd"`
MessageCount int `json:"message_count"`
CWD string `json:"cwd"`
HasFileEdits bool `json:"has_file_edits"`
CacheEfficiency float64 `json:"cache_efficiency"`
WasteFlags []string `json:"waste_flags"`
ContextLength int `json:"context_length"`
IsRunning bool `json:"is_running"`
IsStuck bool `json:"is_stuck"`
PID int `json:"pid,omitempty"`
IdleMinutes float64 `json:"idle_minutes,omitempty"`
}
func DiscoverRecentSessions ¶ added in v0.6.0
func DiscoverRecentSessions(claudeDir string, limit int) ([]*SessionSummary, error)
DiscoverRecentSessions returns at most limit sessions, sorted by file modification time. This avoids parsing all JSONL files by only parsing the most recently modified ones.
func DiscoverSessions ¶
func DiscoverSessions(claudeDir string) ([]*SessionSummary, error)
func DiscoverTodaySessions ¶
func DiscoverTodaySessions(claudeDir string) ([]*SessionSummary, error)
DiscoverTodaySessions returns only sessions with activity today.
func ParseSessionFile ¶
func ParseSessionFile(path string) (*SessionSummary, error)
type ToolCall ¶ added in v0.9.1
type ToolCall struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Input json.RawMessage `json:"input,omitempty"`
Result string `json:"result,omitempty"`
IsError bool `json:"is_error,omitempty"`
}
ToolCall represents a single tool_use invocation from an assistant message, optionally paired with its matching tool_result from the following user message.