Documentation
¶
Index ¶
- func RefreshCache(ctx context.Context, cfg *config.Config, sessionID string, segment string) error
- func RenderOutput(format string, segments map[string]string) (string, error)
- func RenderSegment(tmplStr string, data map[string]any) (string, error)
- func Run(ctx context.Context, cfg *config.Config) (string, error)
- func SpawnBackgroundRefresh(sessionID, segment string)
- type BackgroundRefresher
- type CacheData
- type ClaudeInput
- type FileCache
- type ResolvedConfig
- type ResolvedSegment
- type SegmentCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RefreshCache ¶
RefreshCache is called by background refresh command
func RenderOutput ¶
RenderOutput renders the final output template with all segment outputs
func RenderSegment ¶
RenderSegment renders a segment template with the given data
func SpawnBackgroundRefresh ¶
func SpawnBackgroundRefresh(sessionID, segment string)
SpawnBackgroundRefresh spawns a background process to refresh a segment
Types ¶
type BackgroundRefresher ¶
type BackgroundRefresher struct {
// contains filtered or unexported fields
}
BackgroundRefresher handles async cache updates
func NewBackgroundRefresher ¶
func NewBackgroundRefresher(cache *FileCache, cacheData *CacheData) *BackgroundRefresher
NewBackgroundRefresher creates a refresher for async updates
func (*BackgroundRefresher) IsPending ¶
func (r *BackgroundRefresher) IsPending(segment string) bool
IsPending checks if a segment is marked for refresh
func (*BackgroundRefresher) MarkPending ¶
func (r *BackgroundRefresher) MarkPending(segment string)
MarkPending marks a segment as needing refresh
type CacheData ¶
type CacheData struct {
Segments map[string]SegmentCache `json:"segments"`
UpdatedAt time.Time `json:"updated_at"`
}
CacheData represents the cached data structure
type ClaudeInput ¶
type ClaudeInput struct {
HookEventName string `json:"hook_event_name"`
SessionID string `json:"session_id"`
TranscriptPath string `json:"transcript_path"`
CWD string `json:"cwd"`
Model struct {
ID string `json:"id"`
DisplayName string `json:"display_name"`
} `json:"model"`
Workspace struct {
CurrentDir string `json:"current_dir"`
ProjectDir string `json:"project_dir"`
} `json:"workspace"`
Version string `json:"version"`
OutputStyle struct {
Name string `json:"name"`
} `json:"output_style"`
Cost struct {
TotalCostUSD float64 `json:"total_cost_usd"`
TotalDurationMS int64 `json:"total_duration_ms"`
TotalAPIDurationMS int64 `json:"total_api_duration_ms"`
TotalLinesAdded int `json:"total_lines_added"`
TotalLinesRemoved int `json:"total_lines_removed"`
} `json:"cost"`
ContextWindow struct {
TotalInputTokens int `json:"total_input_tokens"`
TotalOutputTokens int `json:"total_output_tokens"`
ContextWindowSize int `json:"context_window_size"`
UsedPercentage float64 `json:"used_percentage"`
RemainingPercentage float64 `json:"remaining_percentage"`
CurrentUsage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
CacheCreationTokens int `json:"cache_creation_input_tokens"`
CacheReadTokens int `json:"cache_read_input_tokens"`
} `json:"current_usage"`
} `json:"context_window"`
}
ClaudeInput represents the JSON input from Claude Code
func ReadClaudeInput ¶
func ReadClaudeInput() (*ClaudeInput, error)
ReadClaudeInput reads and parses Claude's JSON input from stdin
func (*ClaudeInput) ToTemplateData ¶
func (c *ClaudeInput) ToTemplateData() map[string]any
ToTemplateData converts ClaudeInput to template-friendly map
type FileCache ¶
type FileCache struct {
// contains filtered or unexported fields
}
FileCache provides file-based caching with TTL for status line data
func NewFileCache ¶
NewFileCache creates a new file-based cache for the given session
func (*FileCache) Get ¶
func (c *FileCache) Get(cache *CacheData, segment string) (data map[string]any, ok bool, stale bool)
Get retrieves segment data from cache
type ResolvedConfig ¶
type ResolvedConfig struct {
Format string
Segments map[string]ResolvedSegment
}
ResolvedConfig holds the resolved configuration with defaults applied
func ResolveConfig ¶
func ResolveConfig(cfg *config.Config) *ResolvedConfig
ResolveConfig applies defaults to the status line configuration
type ResolvedSegment ¶
ResolvedSegment holds resolved segment configuration