files

package
v0.25.0 Latest Latest
Warning

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

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

Documentation

Overview

Package files provides reusable file scanning and filtering logic. It is used by both the TUI file picker and the HTTP /api/sessions/{id}/files endpoint.

Index

Constants

View Source
const MaxScanEntries = 5000

MaxScanEntries is the cap on total entries returned by a single scan.

Variables

View Source
var SkipDirs = map[string]bool{
	".git":         true,
	"node_modules": true,
	"vendor":       true,
	".next":        true,
	"dist":         true,
	"build":        true,
	"__pycache__":  true,
	".venv":        true,
	".cache":       true,
	".idea":        true,
	".vscode":      true,
}

SkipDirs are directory names that are always skipped during scanning.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Path  string `json:"path"`
	IsDir bool   `json:"is_dir"`
}

Entry represents a file or directory relative to a workspace root.

func Filter

func Filter(entries []Entry, query string, limit int) []Entry

Filter returns entries matching query, ranked: exact > prefix > contains. Both the full path and the basename are checked. Results are capped to limit. All entries are scanned to guarantee correct ranking; truncation is applied only to the final composed result.

type Scanner

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

Scanner caches file entries per workDir. Thread-safe. Callers create their own instance; there is no package-level global.

func NewScanner

func NewScanner() *Scanner

NewScanner returns a Scanner with a 30-second TTL.

func (*Scanner) Invalidate

func (s *Scanner) Invalidate(workDir string)

Invalidate forces a re-scan for the given workDir on the next call to Scan.

func (*Scanner) Scan

func (s *Scanner) Scan(workDir string) []Entry

Scan returns file entries for workDir, using a cached result if fresh.

Jump to

Keyboard shortcuts

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