Documentation
¶
Overview ¶
Package filescan provides shared file scanning and token estimation utilities
Index ¶
Constants ¶
const ( TokenThresholdSafe = 10000 // Files under this are safe to read fully TokenThresholdLarge = 25000 // Files under this can be read with care TokenThresholdMax = 25000 // Claude-code's max file read limit BytesPerToken = 4 // Rough estimate for text files )
Token thresholds (matching claude-code limits)
Variables ¶
var BinaryExtensions = map[string]bool{ ".exe": true, ".bin": true, ".so": true, ".dylib": true, ".dll": true, ".png": true, ".jpg": true, ".jpeg": true, ".gif": true, ".ico": true, ".webp": true, ".zip": true, ".tar": true, ".gz": true, ".rar": true, ".7z": true, ".pdf": true, ".doc": true, ".docx": true, ".xls": true, ".xlsx": true, ".mp3": true, ".mp4": true, ".avi": true, ".mov": true, ".mkv": true, ".woff": true, ".woff2": true, ".ttf": true, ".eot": true, ".otf": true, ".pyc": true, ".pyo": true, ".class": true, ".o": true, ".a": true, ".sqlite": true, ".db": true, }
BinaryExtensions is the set of extensions to skip when IgnoreBinary is true
Functions ¶
This section is empty.
Types ¶
type FileInfo ¶
type FileInfo struct {
Path string
RelPath string // Relative to scan root
Size int64
EstimatedTokens int
IsDir bool
}
FileInfo holds basic file information with token estimation
func (*FileInfo) TokenCategory ¶
TokenCategory returns the token budget category for a file
type ScanOptions ¶
type ScanOptions struct {
// IgnoreDirs is a set of directory names to skip
IgnoreDirs map[string]bool
// IgnoreHidden skips files and dirs starting with "."
IgnoreHidden bool
// IgnoreBinary skips common binary file extensions
IgnoreBinary bool
// MaxDepth limits recursion depth (0 = unlimited)
MaxDepth int
}
ScanOptions configures the scanner behavior
func DefaultOptions ¶
func DefaultOptions() ScanOptions
DefaultOptions returns sensible defaults for code scanning
type ScanResult ¶
type ScanResult struct {
Root string
Files []FileInfo
TotalFiles int
TotalTokens int
SafeCount int
LargeCount int
OversizedCount int
}
ScanResult holds the results of a directory scan
func Scan ¶
func Scan(root string, opts ScanOptions) (*ScanResult, error)
Scan walks a directory and collects file information with token estimates
func ScanPaths ¶
func ScanPaths(paths []string, opts ScanOptions) (*ScanResult, error)
ScanPaths scans multiple paths and combines results
func (*ScanResult) FilterByCategory ¶
func (r *ScanResult) FilterByCategory(category string) []FileInfo
FilterByCategory returns files matching the given category
func (*ScanResult) HasLargeFiles ¶
func (r *ScanResult) HasLargeFiles() bool
HasLargeFiles returns true if there are any large or oversized files
func (*ScanResult) Manifest ¶
func (r *ScanResult) Manifest() string
Manifest generates a human-readable token budget manifest
func (*ScanResult) MarkdownSection ¶
func (r *ScanResult) MarkdownSection() string
MarkdownSection generates a markdown section for embedding in codebase index