filefinder

package
v2.33.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package filefinder provides an in-memory file index with trigram matching, fuzzy search, and filesystem watching. It is designed to power file-finding features on workspace agents.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = xerrors.New("engine is closed")

ErrClosed is returned when operations are attempted on a closed engine.

Functions

This section is empty.

Types

type Engine

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

Engine is the main file finder. Safe for concurrent use.

func NewEngine

func NewEngine(logger slog.Logger) *Engine

NewEngine creates a new Engine.

func (*Engine) AddRoot

func (e *Engine) AddRoot(ctx context.Context, root string) error

AddRoot adds a directory root to the engine.

func (*Engine) Close

func (e *Engine) Close() error

Close shuts down the engine.

func (*Engine) Rebuild

func (e *Engine) Rebuild(ctx context.Context, root string) error

Rebuild forces a complete re-walk and re-index of a root.

func (*Engine) RemoveRoot

func (e *Engine) RemoveRoot(root string) error

RemoveRoot stops watching a root and removes it.

func (*Engine) Search

func (e *Engine) Search(_ context.Context, query string, opts SearchOptions) ([]Result, error)

Search performs a fuzzy file search across all roots.

type FSEvent

type FSEvent struct {
	Op    FSEventOp
	Path  string
	IsDir bool
}

FSEvent represents a filesystem change event.

type FSEventOp

type FSEventOp uint8

FSEventOp represents the type of filesystem operation.

const (
	OpCreate FSEventOp = iota
	OpRemove
	OpRename
	OpModify
)

Filesystem operations reported by the watcher.

type FileFlag

type FileFlag uint16

FileFlag represents the type of filesystem entry.

const (
	FlagFile    FileFlag = 0
	FlagDir     FileFlag = 1
	FlagSymlink FileFlag = 2
)

type Index

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

Index is an append-only in-memory file index with snapshot support.

func NewIndex

func NewIndex() *Index

NewIndex creates an empty Index.

func (*Index) Add

func (idx *Index) Add(path string, flags uint16) uint32

Add inserts a path into the index, tombstoning any previous entry.

func (*Index) Has

func (idx *Index) Has(path string) bool

Has reports whether path exists (not deleted) in the index.

func (*Index) Len

func (idx *Index) Len() int

Len returns the number of live (non-deleted) documents.

func (*Index) Remove

func (idx *Index) Remove(path string) bool

Remove marks the entry for path as deleted.

func (*Index) Snapshot

func (idx *Index) Snapshot() *Snapshot

Snapshot returns a frozen read-only view of the index.

type Result

type Result struct {
	Path  string
	Score float32
	IsDir bool
}

Result is a scored search result returned to callers.

type SearchOptions

type SearchOptions struct {
	Limit         int
	MaxCandidates int
}

SearchOptions controls search behavior.

func DefaultSearchOptions

func DefaultSearchOptions() SearchOptions

DefaultSearchOptions returns sensible default search options.

type Snapshot

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

Snapshot is a frozen, read-only view of the index at a point in time.

Jump to

Keyboard shortcuts

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