Documentation
¶
Overview ¶
Package analytics provides terminal escape code extraction and analysis
Index ¶
- func DescribeSGR(params string) string
- func DescribeSimpleEscape(secondByte byte) string
- func GetDECPrivateModeDescription(mode string) string
- func GetEraseInDisplayDescription(params string) string
- func GetEraseInLineDescription(params string) string
- func GetOSCDescription(cmd string) string
- type EscapeCategory
- type EscapeCodeEntry
- type EscapeCodeParser
- type EscapeCodeStats
- type EscapeCodeStore
- func (s *EscapeCodeStore) Clear()
- func (s *EscapeCodeStore) Export() ([]byte, error)
- func (s *EscapeCodeStore) GetAll() []EscapeCodeEntry
- func (s *EscapeCodeStore) GetByCategory(category EscapeCategory) []EscapeCodeEntry
- func (s *EscapeCodeStore) GetBySession(sessionID string) []EscapeCodeEntry
- func (s *EscapeCodeStore) GetStats() EscapeCodeStats
- func (s *EscapeCodeStore) IsEnabled() bool
- func (s *EscapeCodeStore) Record(sessionID string, rawBytes []byte, category EscapeCategory, description string)
- func (s *EscapeCodeStore) SetEnabled(enabled bool)
- type ParsedEscapeCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DescribeSGR ¶
DescribeSGR returns a human-readable description of SGR parameters
func DescribeSimpleEscape ¶
DescribeSimpleEscape returns a description for a simple 2-byte escape
func GetDECPrivateModeDescription ¶
GetDECPrivateModeDescription returns a human-readable description for a DEC private mode
func GetEraseInDisplayDescription ¶
Erase in Display descriptions
func GetEraseInLineDescription ¶
Erase in Line descriptions
func GetOSCDescription ¶
GetOSCDescription returns a human-readable description for an OSC command
Types ¶
type EscapeCategory ¶
type EscapeCategory string
EscapeCategory represents the type of escape sequence
const ( CategoryCSI EscapeCategory = "CSI" // Control Sequence Introducer \x1b[ CategoryOSC EscapeCategory = "OSC" // Operating System Command \x1b] CategoryDCS EscapeCategory = "DCS" // Device Control String \x1bP CategoryPM EscapeCategory = "PM" // Privacy Message \x1b^ CategoryAPC EscapeCategory = "APC" // Application Program Command \x1b_ CategorySOS EscapeCategory = "SOS" // Start of String \x1bX CategoryC1 EscapeCategory = "C1" // C1 control codes CategorySimple EscapeCategory = "Simple" // Simple 2-char escapes CategoryDECPriv EscapeCategory = "DECPriv" // DEC Private modes \x1b[? CategorySGR EscapeCategory = "SGR" // Select Graphic Rendition (colors/styles) CategoryCursor EscapeCategory = "Cursor" // Cursor positioning CategoryErase EscapeCategory = "Erase" // Screen/line erase CategoryScroll EscapeCategory = "Scroll" // Scroll region CategoryCharset EscapeCategory = "Charset" // Character set selection CategoryUnknown EscapeCategory = "Unknown" // Unknown sequence )
type EscapeCodeEntry ¶
type EscapeCodeEntry struct {
Code string `json:"code"` // Hex-encoded sequence
HumanReadable string `json:"humanReadable"` // Description
Category EscapeCategory `json:"category"` // Type of sequence
Count int64 `json:"count"` // How many times seen
FirstSeen time.Time `json:"firstSeen"` // First occurrence
LastSeen time.Time `json:"lastSeen"` // Most recent occurrence
SessionIDs []string `json:"sessionIds"` // Sessions that produced this code
}
EscapeCodeEntry represents a tracked escape sequence
type EscapeCodeParser ¶
type EscapeCodeParser struct {
// contains filtered or unexported fields
}
EscapeCodeParser extracts escape sequences from terminal output
func NewEscapeCodeParser ¶
func NewEscapeCodeParser(store *EscapeCodeStore, sessionID string) *EscapeCodeParser
NewEscapeCodeParser creates a new parser with the given store and session ID
func (*EscapeCodeParser) IsEnabled ¶
func (p *EscapeCodeParser) IsEnabled() bool
IsEnabled returns whether parsing is enabled
func (*EscapeCodeParser) Parse ¶
func (p *EscapeCodeParser) Parse(data []byte) []byte
Parse extracts all escape sequences from data and records them to the store. Returns the original data unchanged (passthrough).
func (*EscapeCodeParser) SetEnabled ¶
func (p *EscapeCodeParser) SetEnabled(enabled bool)
SetEnabled enables or disables escape code parsing
type EscapeCodeStats ¶
type EscapeCodeStats struct {
Enabled bool `json:"enabled"`
TotalCodes int64 `json:"totalCodes"` // Total codes recorded
UniqueCodes int `json:"uniqueCodes"` // Unique sequences
CategoryCounts map[EscapeCategory]int64 `json:"categoryCounts"` // Count by category
TopCodes []EscapeCodeEntry `json:"topCodes"` // Most frequent codes
RecentCodes []EscapeCodeEntry `json:"recentCodes"` // Recently seen codes
}
EscapeCodeStats provides aggregated statistics
type EscapeCodeStore ¶
type EscapeCodeStore struct {
// contains filtered or unexported fields
}
EscapeCodeStore provides thread-safe storage for escape code analytics
func GetGlobalStore ¶
func GetGlobalStore() *EscapeCodeStore
GetGlobalStore returns the singleton escape code store
func NewEscapeCodeStore ¶
func NewEscapeCodeStore() *EscapeCodeStore
NewEscapeCodeStore creates a new store with default settings
func (*EscapeCodeStore) Export ¶
func (s *EscapeCodeStore) Export() ([]byte, error)
Export returns all data as JSON
func (*EscapeCodeStore) GetAll ¶
func (s *EscapeCodeStore) GetAll() []EscapeCodeEntry
GetAll returns all entries
func (*EscapeCodeStore) GetByCategory ¶
func (s *EscapeCodeStore) GetByCategory(category EscapeCategory) []EscapeCodeEntry
GetByCategory returns entries for a specific category
func (*EscapeCodeStore) GetBySession ¶
func (s *EscapeCodeStore) GetBySession(sessionID string) []EscapeCodeEntry
GetBySession returns entries for a specific session
func (*EscapeCodeStore) GetStats ¶
func (s *EscapeCodeStore) GetStats() EscapeCodeStats
GetStats returns aggregated statistics
func (*EscapeCodeStore) IsEnabled ¶
func (s *EscapeCodeStore) IsEnabled() bool
IsEnabled returns whether tracking is enabled
func (*EscapeCodeStore) Record ¶
func (s *EscapeCodeStore) Record(sessionID string, rawBytes []byte, category EscapeCategory, description string)
Record adds or updates an escape code entry
func (*EscapeCodeStore) SetEnabled ¶
func (s *EscapeCodeStore) SetEnabled(enabled bool)
SetEnabled enables or disables tracking
type ParsedEscapeCode ¶
type ParsedEscapeCode struct {
RawBytes []byte // Original bytes
HexEncoded string // Hex representation for display
Category EscapeCategory // Type of sequence
Description string // Human-readable description
StartOffset int // Position in original data
EndOffset int // End position in original data
}
ParsedEscapeCode represents a single parsed escape sequence