Documentation
¶
Overview ¶
Package stats defines constants for context size monitoring, health checks, and display formatting.
Index ¶
Constants ¶
const ( // ContextSizeCounterPrefix is the state file prefix for per-session prompt counters. ContextSizeCounterPrefix = "context-check-" // ContextSizeLogFile is the log file name within .context/logs/. ContextSizeLogFile = "check-context-size.log" // ContextWindowThresholdPct is the percentage of context window usage // that triggers an independent warning, regardless of prompt count. ContextWindowThresholdPct = 80 // ContextSizeBillingWarnedPrefix is the state file prefix for the one-shot billing warning guard. ContextSizeBillingWarnedPrefix = "billing-warned-" // ContextSizeInjectionOversizeFlag is the state file name for the injection-oversize one-shot flag. ContextSizeInjectionOversizeFlag = "injection-oversize" // JsonlPathCachePrefix is the state file prefix for cached JSONL file paths. JsonlPathCachePrefix = "jsonl-path-" // ContextSizeOversizeSepLen is the separator length for the oversize flag file header. ContextSizeOversizeSepLen = 35 )
Context size hook configuration.
const ( // FilePrefix is the filename prefix for per-session stats JSONL files. FilePrefix = "stats-" // ReadBufSize is the byte buffer size for reading new lines // from stats files during follow/stream mode. ReadBufSize = 8192 // HeaderTime is the column header label for timestamp. HeaderTime = "TIME" // HeaderSession is the column header label for session ID. HeaderSession = "SESSION" // HeaderPrompt is the column header label for prompt count. HeaderPrompt = "PROMPT" // HeaderTokens is the column header label for token count. HeaderTokens = "TOKENS" // HeaderPct is the column header label for percentage. HeaderPct = "PCT" // HeaderEvent is the column header label for the event type. HeaderEvent = "EVENT" // SepTime is the column separator for the time field. SepTime = "-------------------" // SepSession is the column separator for the session field. SepSession = "--------" // SepPrompt is the column separator for the prompt field. SepPrompt = "------" // SepTokens is the column separator for the tokens field. SepTokens = "--------" // SepPct is the column separator for the percentage field. SepPct = "----" // SepEvent is the column separator for the event field. SepEvent = "------------" )
Stats display configuration.
const ( StatusOK = "ok" StatusWarning = "warning" StatusError = "error" StatusInfo = "info" )
Check result status constants used by doctor, drift, and other health checks.
const ( IconOK = "✓" IconWarning = "⚠" IconError = "✗" IconInfo = "○" IconUnknown = "?" )
Unicode icons for status display.
const ( // ResourcesStatusCol is the column where the status indicator starts // in the resources text output. ResourcesStatusCol = 52 // ResourcesLabelWidth is the left-aligned label column width. ResourcesLabelWidth = 7 )
Resources display formatting.
const ( // ThresholdMemoryWarnPct is the memory usage percentage that triggers a warning. ThresholdMemoryWarnPct = 80 // ThresholdMemoryDangerPct is the memory usage percentage that triggers a danger alert. ThresholdMemoryDangerPct = 90 // ThresholdSwapWarnPct is the swap usage percentage that triggers a warning. ThresholdSwapWarnPct = 50 // ThresholdSwapDangerPct is the swap usage percentage that triggers a danger alert. ThresholdSwapDangerPct = 75 // ThresholdDiskWarnPct is the disk usage percentage that triggers a warning. ThresholdDiskWarnPct = 85 // ThresholdDiskDangerPct is the disk usage percentage that triggers a danger alert. ThresholdDiskDangerPct = 95 // ThresholdLoadWarnRatio is the load-to-CPU ratio that triggers a warning. ThresholdLoadWarnRatio = 0.8 // ThresholdLoadDangerRatio is the load-to-CPU ratio that triggers a danger alert. ThresholdLoadDangerRatio = 1.5 // ThresholdBytesPerGiB is the number of bytes in one gibibyte. ThresholdBytesPerGiB = 1 << 30 )
Resource threshold constants for health evaluation.
const ( // VarAlertMessages is the template variable for resource alert messages. VarAlertMessages = "AlertMessages" // VarPercentage is the template variable for context window percentage. VarPercentage = "Percentage" // VarThreshold is the template variable for a token threshold value. VarThreshold = "Threshold" // VarTokenCount is the template variable for a token count value. VarTokenCount = "TokenCount" )
Template variable keys for resource and context size hooks.
const (
// DefaultLast is the default number of stats entries to display.
DefaultLast = 20
)
Stats command defaults.
const (
// FormatGiB is the precision format for GiB values.
FormatGiB = "%.1f"
)
Resources formatting patterns.
const MaxPreviewLen = 60
MaxPreviewLen is the maximum length for preview lines before truncation.
const PercentMultiplier = 100
PercentMultiplier is the multiplier for converting ratios to percentages.
Variables ¶
This section is empty.
Functions ¶
func StatusIcon ¶
StatusIcon returns the Unicode icon for a given status string.
Parameters:
- status: One of StatusOK, StatusWarning, StatusError, or StatusInfo
Returns:
- string: A single Unicode character representing the status
Types ¶
This section is empty.