projectfiles

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TextLimit  = 1 << 20
	ImageLimit = 5 << 20
	EntryLimit = 5000
)
View Source
const FindIndexLimit = 200000

Variables

View Source
var (
	ErrInvalidPath     = errors.New("projectfiles: invalid path")
	ErrPathOutsideRoot = errors.New("projectfiles: path outside root")
	ErrPathDenied      = errors.New("projectfiles: path denied")
	ErrNotFound        = errors.New("projectfiles: not found")
	ErrNotADirectory   = errors.New("projectfiles: not a directory")
	ErrNotAFile        = errors.New("projectfiles: not a file")
	ErrRootUnavailable = errors.New("projectfiles: root unavailable")
	ErrRootNotFound    = errors.New("projectfiles: root not found")
)
View Source
var ErrInvalidQuery = errors.New("projectfiles: invalid query")

Functions

func GitReadArgs

func GitReadArgs(
	ctx context.Context,
	runner worktree.StreamingGitRunner,
	root, command string,
	args ...string,
) ([]string, error)

GitReadArgs applies the shared read-only policy, discovering filter drivers afresh on each call.

func OpenRegularFile

func OpenRegularFile(root *os.Root, path string) (*os.File, error)

OpenRegularFile confines the open and rejects special descriptors even after a path swap.

func Sensitive

func Sensitive(path string) bool

func ValidatePath

func ValidatePath(path string) error

Types

type Content

type Content struct {
	Path                      string
	Kind                      ContentKind
	Size                      int64
	Language, Text, ImageMIME string
	ImageData                 []byte
	Sensitive, Truncated      bool
	Revision                  string
}

type ContentKind

type ContentKind string
const (
	ContentKindText      ContentKind = "text"
	ContentKindImage     ContentKind = "image"
	ContentKindBinary    ContentKind = "binary"
	ContentKindSensitive ContentKind = "sensitive"
)

type Entry

type Entry struct {
	Name, Path                  string
	Kind                        EntryKind
	Size                        int64
	Symlink, Ignored, Sensitive bool
	GitStatus                   GitStatus
	ContainsChanges             bool
}

type EntryKind

type EntryKind string
const (
	EntryKindFile      EntryKind = "file"
	EntryKindDirectory EntryKind = "directory"
)

type FileReader

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

func NewReader

func NewReader(opts ...Option) *FileReader

func (*FileReader) List

func (r *FileReader) List(ctx context.Context, root Root, dir string, opts ListOptions) (listing Listing, err error)

func (*FileReader) Read

func (r *FileReader) Read(ctx context.Context, root Root, path string, opts ReadOptions) (content Content, err error)

type FileSearch

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

func NewSearch

func NewSearch(runner worktree.StreamingGitRunner, opts ...workspacefiles.Option) *FileSearch

func (*FileSearch) Find

func (s *FileSearch) Find(ctx context.Context, root Root, query string, limit int) (FindResult, error)

func (*FileSearch) Search

func (s *FileSearch) Search(ctx context.Context, root Root, q SearchQuery) (SearchResult, error)

type FindMatch

type FindMatch struct {
	Path        string
	Kind        EntryKind
	Sensitive   bool
	Score       int
	MatchRanges [][2]int
}

type FindResult

type FindResult struct {
	Results        []FindMatch
	IndexedFiles   int
	IndexTruncated bool
}

type Finder

type Finder interface {
	Find(context.Context, Root, string, int) (FindResult, error)
}

type GitStatus

type GitStatus string

type ListOptions

type ListOptions struct{ ShowIgnored, Refresh bool }

type Listing

type Listing struct {
	Root                         Root
	Path                         string
	Entries                      []Entry
	Truncated, StatusUnavailable bool
}

type Option

type Option func(*FileReader)

func WithGitRunner

func WithGitRunner(runner worktree.StreamingGitRunner) Option

func WithStatusTTL

func WithStatusTTL(ttl time.Duration) Option

WithStatusTTL sets status retention; zero disables retention while keeping coalescing.

type ReadOptions

type ReadOptions struct{ Reveal bool }

type Reader

type Reader interface {
	List(context.Context, Root, string, ListOptions) (Listing, error)
	Read(context.Context, Root, string, ReadOptions) (Content, error)
}

type Root

type Root struct {
	Kind                                                    RootKind
	WorkspaceID, WorktreeID, Name, Branch, BaseRef, AbsPath string
}

func CanonicalRoot

func CanonicalRoot(root Root) (Root, error)

type RootKind

type RootKind string
const (
	RootKindWorkspace RootKind = "workspace"
	RootKindWorktree  RootKind = "worktree"
)

type RootRef

type RootRef struct{ WorkspaceID, WorktreeID, SessionID string }

type RootResolver

type RootResolver interface {
	Resolve(context.Context, RootRef) (Root, error)
}

type SearchFile

type SearchFile struct {
	Path             string
	Matches          []SearchMatch
	TruncatedMatches bool
}

type SearchMatch

type SearchMatch struct {
	Line, Column int
	Text         string
	Ranges       [][2]int
	TextOffset   int
}

type SearchQuery

type SearchQuery struct {
	Pattern                         string
	Regex, CaseSensitive, WholeWord bool
	Include, Exclude                []string
}

type SearchResult

type SearchResult struct {
	Files                    []SearchFile
	TotalFiles, TotalMatches int
	Truncated, TimedOut      bool
	SensitiveExcluded        int
	Engine                   string
}

type Searcher

type Searcher interface {
	Search(context.Context, Root, SearchQuery) (SearchResult, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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