watch

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const AnalysisPrompt = `` /* 536-byte string literal not displayed */

AnalysisPrompt is the prompt template for screen analysis

Variables

This section is empty.

Functions

func CheckNotificationPermissions

func CheckNotificationPermissions() bool

CheckNotificationPermissions checks if notifications are likely to work Note: This is a best-effort check; macOS doesn't provide a programmatic way to verify

func Cleanup

func Cleanup(captures []*ScreenCapture) error

Cleanup removes screenshot files

func CleanupPath

func CleanupPath(path string) error

CleanupPath removes a single screenshot file

func CompareImages

func CompareImages(path1, path2 string, threshold float64) (bool, error)

CompareImages compares two image files and returns if they differ significantly

func ComputeHash

func ComputeHash(imagePath string) (uint64, error)

ComputeHash generates a perceptual hash for an image file Returns a 64-bit hash where similar images have similar hash values

func GetDisplayCount

func GetDisplayCount() int

GetDisplayCount returns the number of connected displays

func GetDisplayInfo

func GetDisplayInfo() string

GetDisplayInfo returns formatted display information string

func HammingDistance

func HammingDistance(hash1, hash2 uint64) int

HammingDistance returns the number of differing bits between two hashes

func HasSignificantChange

func HasSignificantChange(oldHash, newHash uint64, threshold float64) bool

HasSignificantChange determines if two images differ significantly threshold is the minimum difference ratio (0.0-1.0) to consider significant Default recommendation: 0.15 (15% difference)

func HashDifferenceRatio

func HashDifferenceRatio(hash1, hash2 uint64) float64

HashDifferenceRatio returns the percentage of differing bits (0.0-1.0)

func QuickDiff

func QuickDiff(path1, path2 string) bool

QuickDiff performs a quick file-size based diff before computing hash Returns true if files are likely different (different sizes or missing)

func SendAnalysisNotification

func SendAnalysisNotification(result *AnalysisResult) error

SendAnalysisNotification sends a summary notification for analysis results

func SendFindingNotification

func SendFindingNotification(finding Finding) error

SendFindingNotification sends a notification for a watch finding

func SendNotification

func SendNotification(title, message string) error

SendNotification sends a macOS system notification

func SendNotificationWithSound

func SendNotificationWithSound(title, message, sound string) error

SendNotificationWithSound sends a macOS notification with sound

func SendNotificationWithSubtitle

func SendNotificationWithSubtitle(title, subtitle, message string) error

SendNotificationWithSubtitle sends a notification with a subtitle

Types

type AnalysisResult

type AnalysisResult struct {
	Timestamp    time.Time     `json:"timestamp"`
	ScreenCount  int           `json:"screen_count"`
	Findings     []Finding     `json:"findings"`
	RawResponse  string        `json:"raw_response,omitempty"`
	AnalysisTime time.Duration `json:"analysis_time"`
}

AnalysisResult contains the LLM's findings from analyzing a screenshot

func AnalyzeOnce

func AnalyzeOnce(ctx context.Context, analyzeFunc AnalyzeFunc, tempDir string) (*AnalysisResult, error)

AnalyzeOnce performs a one-time screen capture and analysis

func (*AnalysisResult) ErrorCount

func (r *AnalysisResult) ErrorCount() int

ErrorCount returns the number of ERROR findings

func (*AnalysisResult) HasFindings

func (r *AnalysisResult) HasFindings() bool

HasFindings returns true if the analysis found any issues

func (*AnalysisResult) WarningCount

func (r *AnalysisResult) WarningCount() int

WarningCount returns the number of WARNING findings

type AnalyzeFunc

type AnalyzeFunc func(prompt string, images []*assistant.ImageData) (string, error)

AnalyzeFunc is the function signature for analyzing screenshots

type Finding

type Finding struct {
	Type        FindingType `json:"type"`
	Description string      `json:"description"`
	Suggestion  string      `json:"suggestion,omitempty"`
}

Finding represents a single detected issue from screen analysis

type FindingType

type FindingType string

FindingType represents the type of finding from analysis

const (
	FindingError       FindingType = "ERROR"
	FindingWarning     FindingType = "WARNING"
	FindingImprovement FindingType = "IMPROVEMENT"
)

type MonitorStatus

type MonitorStatus struct {
	State           WatchState    `json:"state"`
	DisplayCount    int           `json:"display_count"`
	TotalCaptures   int           `json:"total_captures"`
	TotalAnalyses   int           `json:"total_analyses"`
	LastCapture     time.Time     `json:"last_capture,omitempty"`
	LastAnalysis    time.Time     `json:"last_analysis,omitempty"`
	AnalysesThisMin int           `json:"analyses_this_min"`
	Uptime          time.Duration `json:"uptime,omitempty"`
	StartTime       time.Time     `json:"start_time,omitempty"`
}

MonitorStatus provides information about the current monitoring state

type ScreenCapture

type ScreenCapture struct {
	Path      string    `json:"path"`
	DisplayID int       `json:"display_id"`
	Width     int       `json:"width"`
	Height    int       `json:"height"`
	Timestamp time.Time `json:"timestamp"`
	Hash      uint64    `json:"hash"`
}

ScreenCapture represents a captured screenshot

func CaptureAll

func CaptureAll(tempDir string) ([]*ScreenCapture, error)

CaptureAll captures all screens and returns ScreenCapture structs

func CaptureOne

func CaptureOne(tempDir string) (*ScreenCapture, error)

CaptureOne captures a single screenshot of all screens combined

type WatchConfig

type WatchConfig struct {
	// Enabled determines if the watch feature is active
	Enabled bool `mapstructure:"enabled"`

	// ChangeThreshold is the percentage difference (0.0-1.0) that triggers analysis
	// Default: 0.15 (15%)
	ChangeThreshold float64 `mapstructure:"change_threshold"`

	// CaptureInterval is how often to check for screen changes
	// Default: 2s
	CaptureInterval time.Duration `mapstructure:"capture_interval"`

	// DebounceInterval is the minimum time between analyses
	// Default: 5s
	DebounceInterval time.Duration `mapstructure:"debounce_interval"`

	// MaxAnalysisPerMin is the rate limit for analyses per minute
	// Default: 6
	MaxAnalysisPerMin int `mapstructure:"max_analysis_per_min"`

	// Notify enables macOS system notifications
	// Default: true
	Notify bool `mapstructure:"notify"`
}

WatchConfig holds configuration for the watch monitor

func DefaultConfig

func DefaultConfig() WatchConfig

DefaultConfig returns the default watch configuration

type WatchMonitor

type WatchMonitor struct {
	// contains filtered or unexported fields
}

WatchMonitor coordinates screen monitoring and analysis

func NewWatchMonitor

func NewWatchMonitor(config WatchConfig, analyzeFunc AnalyzeFunc, tempDir string) *WatchMonitor

NewWatchMonitor creates a new monitor with the given configuration

func (*WatchMonitor) IsRunning

func (m *WatchMonitor) IsRunning() bool

IsRunning returns true if the monitor is actively running

func (*WatchMonitor) Results

func (m *WatchMonitor) Results() <-chan *AnalysisResult

Results returns the channel for receiving analysis results

func (*WatchMonitor) Start

func (m *WatchMonitor) Start() error

Start begins continuous screen monitoring

func (*WatchMonitor) Status

func (m *WatchMonitor) Status() MonitorStatus

Status returns the current monitor status

func (*WatchMonitor) Stop

func (m *WatchMonitor) Stop()

Stop halts the monitoring loop

type WatchState

type WatchState int

WatchState represents the current state of the monitor

const (
	StateIdle WatchState = iota
	StateMonitoring
	StateAnalyzing
)

func (WatchState) String

func (s WatchState) String() string

String returns the string representation of WatchState

Jump to

Keyboard shortcuts

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