Documentation
¶
Overview ¶
Package filewatch monitors file/directory patterns and triggers plan re-evaluation when watched files change. Designed for TDD-style AI loops where code changes should drive plan updates.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintEvent ¶
func PrintEvent(evt ChangeEvent)
PrintEvent prints a colored summary of a ChangeEvent to stdout.
func Run ¶
func Run(ctx context.Context, cfg Config, onTrigger func(ChangeEvent)) error
Run starts the file watcher. It blocks until ctx is cancelled. onTrigger is called after each debounced batch of changes once the state has been updated (relevant tasks reset to pending). Batches are applied one at a time, so onTrigger never runs concurrently with itself; changes that arrive while a batch is being applied make up the next one. Once ctx is cancelled no further batch starts, and Run returns as soon as the one in flight, if any, has finished: onTrigger is never called after Run returns.
Types ¶
type ChangeEvent ¶
type ChangeEvent struct {
// Files is the list of changed file paths (relative to WorkDir).
Files []string
// ResetTaskIDs are the task IDs that were reset to pending.
ResetTaskIDs []int
// Context is a human-readable description of what changed.
Context string
}
ChangeEvent describes a batch of file changes that triggered re-evaluation.
type Config ¶
type Config struct {
// WorkDir is the project root.
WorkDir string
// Globs are file patterns to watch (e.g. "**/*.go", "src/**/*.ts").
Globs []string
// Debounce is the duration to wait after the last change before triggering.
Debounce time.Duration
}
Config holds file-watch configuration.