statusline

package
v0.49.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RefreshCache

func RefreshCache(ctx context.Context, cfg *config.Config, sessionID string, segment string) error

RefreshCache is called by background refresh command

func RenderOutput

func RenderOutput(format string, segments map[string]string) (string, error)

RenderOutput renders the final output template with all segment outputs

func RenderSegment

func RenderSegment(tmplStr string, data map[string]any) (string, error)

RenderSegment renders a segment template with the given data

func Run

func Run(ctx context.Context, cfg *config.Config) (string, error)

Run executes the status line generation

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

func NewFileCache(sessionID string) (*FileCache, error)

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

func (*FileCache) Load

func (c *FileCache) Load() (*CacheData, error)

Load reads the cache from disk

func (*FileCache) Save

func (c *FileCache) Save(cache *CacheData) error

Save writes the cache to disk

func (*FileCache) Set

func (c *FileCache) Set(cache *CacheData, segment string, data map[string]any, ttl time.Duration)

Set stores segment data in 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

type ResolvedSegment struct {
	Enabled  bool
	Format   string
	CacheTTL time.Duration
}

ResolvedSegment holds resolved segment configuration

type SegmentCache

type SegmentCache struct {
	Data      map[string]any `json:"data"`
	UpdatedAt time.Time      `json:"updated_at"`
	TTL       time.Duration  `json:"ttl"`
}

SegmentCache holds cached data for a single segment

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL