watcher

package
v0.0.0-...-3e0f713 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AgentLogLocations = map[string]map[string][]string{
	"copilot": {
		"darwin": {
			"~/Library/Application Support/Code/User/workspaceStorage/*/chatSessions",
			"~/Library/Application Support/Code - Insiders/User/workspaceStorage/*/chatSessions",
		},
		"linux": {
			"~/.config/Code/User/workspaceStorage/*/chatSessions",
			"~/.config/Code - Insiders/User/workspaceStorage/*/chatSessions",
		},
		"windows": {
			"%APPDATA%\\Code\\User\\workspaceStorage\\*\\chatSessions",
			"%APPDATA%\\Code - Insiders\\User\\workspaceStorage\\*\\chatSessions",
		},
	},
	"claude": {
		"darwin": {
			"~/.claude/logs",
			"~/Library/Application Support/Claude/logs",
			"~/Library/Logs/Claude",
		},
		"linux": {
			"~/.claude/logs",
			"~/.config/claude/logs",
			"~/.local/share/claude/logs",
		},
		"windows": {
			"%APPDATA%\\Claude\\logs",
			"%LOCALAPPDATA%\\Claude\\logs",
		},
	},
	"cursor": {
		"darwin": {
			"~/Library/Application Support/Cursor/logs",
			"~/Library/Logs/Cursor",
		},
		"linux": {
			"~/.config/Cursor/logs",
			"~/.local/share/Cursor/logs",
		},
		"windows": {
			"%APPDATA%\\Cursor\\logs",
			"%LOCALAPPDATA%\\Cursor\\logs",
		},
	},
	"cline": {
		"darwin": {
			"~/.vscode/extensions/saoudrizwan.claude-dev-*/logs",
			"~/Library/Application Support/Code/logs/*/exthost",
		},
		"linux": {
			"~/.vscode/extensions/saoudrizwan.claude-dev-*/logs",
			"~/.config/Code/logs/*/exthost",
		},
		"windows": {
			"%USERPROFILE%\\.vscode\\extensions\\saoudrizwan.claude-dev-*\\logs",
			"%APPDATA%\\Code\\logs\\*\\exthost",
		},
	},
	"aider": {
		"darwin": {
			"~/.aider/logs",
			"~/.aider/.aider.history",
		},
		"linux": {
			"~/.aider/logs",
			"~/.aider/.aider.history",
		},
		"windows": {
			"%USERPROFILE%\\.aider\\logs",
			"%USERPROFILE%\\.aider\\.aider.history",
		},
	},
}

AgentLogLocations defines default log paths per OS and agent

Functions

func DiscoverAllAgentLogs

func DiscoverAllAgentLogs() (map[string][]DiscoveredLog, error)

DiscoverAllAgentLogs discovers logs for all known agents

func FindLogFiles

func FindLogFiles(dirPath string) ([]string, error)

FindLogFiles recursively finds log files in a directory

func GetLatestLogFile

func GetLatestLogFile(dirPath string) (string, error)

GetLatestLogFile finds the most recently modified log file in a directory

Types

type Config

type Config struct {
	Registry       *adapters.Registry
	EventQueueSize int
	DebounceMs     int
	Logger         *logrus.Logger
}

Config holds watcher configuration

type DiscoveredLog

type DiscoveredLog struct {
	AgentName string
	Path      string
	IsDir     bool
	Exists    bool
}

DiscoveredLog represents a discovered log file or directory

func DiscoverAgentLogs

func DiscoverAgentLogs(agentName string) ([]DiscoveredLog, error)

DiscoverAgentLogs finds actual log file locations for a specific agent

type Watcher

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

Watcher monitors log files for changes

func NewWatcher

func NewWatcher(config Config) (*Watcher, error)

NewWatcher creates a new file system watcher

func (*Watcher) EventQueue

func (w *Watcher) EventQueue() <-chan *types.AgentEvent

EventQueue returns the channel for receiving parsed events

func (*Watcher) GetStats

func (w *Watcher) GetStats() map[string]interface{}

GetStats returns watcher statistics

func (*Watcher) Start

func (w *Watcher) Start() error

Start begins watching for file changes

func (*Watcher) StartDynamicDiscovery

func (w *Watcher) StartDynamicDiscovery(interval time.Duration, onNewWorkspace func(string, adapters.AgentAdapter))

StartDynamicDiscovery starts a background goroutine that periodically scans for new workspaces

func (*Watcher) Stop

func (w *Watcher) Stop() error

Stop stops watching and cleans up resources

func (*Watcher) Watch

func (w *Watcher) Watch(path string, adapter adapters.AgentAdapter) error

Watch adds a file or directory to watch

func (*Watcher) WatchParentDirs

func (w *Watcher) WatchParentDirs(paths []string, adapter adapters.AgentAdapter) error

WatchParentDirs watches parent directories for new workspaces (e.g., VS Code workspaceStorage) This enables detecting new workspaces when they are created (user opens new project in VS Code)

Jump to

Keyboard shortcuts

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