filewatch

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package filewatch provides shared file discovery for agentwatch sources. It handles directory walking with glob pattern filters, age-window filtering, and efficient re-scanning by tracking directory modification times.

Sources (claude, codex, gemini) use Walker in their Discover() implementations. Keep this package internal until a custom source author demonstrably needs it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Path    string
	ModTime time.Time
}

Entry is a discovered file.

type Option

type Option func(*Walker)

Option configures a Walker.

func WithClock

func WithClock(clock func() time.Time) Option

WithClock injects a clock function used to evaluate age windows. Intended for testing; production callers should omit this option.

func WithFollowSymlinks(follow bool) Option

WithFollowSymlinks controls whether symlinks that point to directories are followed during the walk. Symlinks pointing to regular files are always followed. The default is false.

func WithMaxAge

func WithMaxAge(d time.Duration) Option

WithMaxAge limits discovery to files whose modification time is within d of the current time. A zero duration (the default) disables age filtering.

func WithPattern

func WithPattern(pattern string) Option

WithPattern adds a glob pattern that file names must match (e.g. "*.jsonl"). Multiple patterns are ORed: a file matching any pattern is included. If no pattern is added, all files are included.

type Walker

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

Walker walks one or more directory trees and returns files that satisfy the configured filters. Repeated calls to Discover skip directories whose modification time has not changed since the previous scan.

func New

func New(roots []string, opts ...Option) *Walker

New creates a Walker rooted at the given roots.

func (*Walker) Discover

func (w *Walker) Discover(ctx context.Context) ([]Entry, error)

Discover walks all configured roots and returns matching files. Missing root directories are silently skipped. A cancelled context causes an early return with the context error.

Jump to

Keyboard shortcuts

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