Help us shape the future of Go! Take the 2026 Go Developer Survey

smart

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package smart filters files that are unlikely to be useful LLM context: generated artifacts, lockfiles, minified bundles, and oversized files that .gitignore often misses. It relies on filename heuristics, generated-header sniffing, and a per-file token guardrail. The language-specific rules live in internal/lang.

Index

Constants

View Source
const DefaultMaxTokens = 15000

DefaultMaxTokens is the per-file guardrail used when no limit is given.

Variables

This section is empty.

Functions

func IsGeneratedHeader

func IsGeneratedHeader(content []byte) bool

IsGeneratedHeader inspects the first 5 lines (bounded by 1KB) for generator comments.

Types

type Evaluator

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

Evaluator checks files against the token guardrail and generated headers, delegating language-specific rules to the central lang registry.

func New

func New(maxTokens int) *Evaluator

New returns an Evaluator using the given per-file token ceiling. A non-positive maxTokens falls back to DefaultMaxTokens.

func (*Evaluator) ExceedsTokenLimit added in v1.3.0

func (e *Evaluator) ExceedsTokenLimit(tokens int) (bool, string)

ExceedsTokenLimit reports whether tokens breaches the per-file guardrail. It lets callers that already ran the header and name checks skip straight to the count check without re-running them.

func (*Evaluator) ShouldSkip

func (e *Evaluator) ShouldSkip(path string, content []byte, tokens int) (bool, string)

ShouldSkip reports whether a file should be excluded by the smart filter, along with a human-readable reason. Name-based rules run here too, but callers that already ran ShouldSkipPath can avoid the redundant check by only invoking ShouldSkip on surviving candidates.

func (*Evaluator) ShouldSkipMeta

func (e *Evaluator) ShouldSkipMeta(path string, approxTokens int) (bool, string)

ShouldSkipMeta reports whether a file should be excluded using only its path and an approximate token count (e.g. size/4). It backs the picker's structure-first pass, letting the skeleton skip files that name rules or the token guardrail would drop, without reading any content.

func (*Evaluator) ShouldSkipPath

func (e *Evaluator) ShouldSkipPath(path string) (bool, string)

ShouldSkipPath reports whether a file should be excluded based on its name alone, without reading or tokenizing its content. It lets callers drop lockfiles, generated artifacts, and bundles before any I/O or CPU work. Results are memoized per path: every pass that sees the same file (walker pre-read filter, content processor, skeleton) shares the first answer.

Jump to

Keyboard shortcuts

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