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

context

package
v1.233.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxFiles is the default maximum number of files to include.
	DefaultMaxFiles = 100

	// DefaultMaxSizeMB is the default maximum total size in MB.
	DefaultMaxSizeMB = 10

	// DefaultCacheTTL is the default cache TTL in seconds.
	DefaultCacheTTL = 300

	// MBToBytes conversion factor.
	MBToBytes = 1024 * 1024
)

Variables

This section is empty.

Functions

func FormatFilesContext

func FormatFilesContext(result *DiscoveryResult) string

FormatFilesContext formats discovered files as context string for AI.

func ValidateConfig

func ValidateConfig(config *schema.AIContextSettings) error

ValidateConfig validates context discovery configuration.

Types

type DiscoveredFile

type DiscoveredFile struct {
	Path         string
	RelativePath string
	Size         int64
	ModTime      time.Time
	Content      []byte
}

DiscoveredFile represents a file discovered by the context loader.

type Discoverer

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

Discoverer handles automatic context file discovery.

func NewDiscoverer

func NewDiscoverer(basePath string, config *schema.AIContextSettings) (*Discoverer, error)

NewDiscoverer creates a new context discoverer.

func (*Discoverer) Discover

func (d *Discoverer) Discover() (*DiscoveryResult, error)

Discover finds and loads files based on configuration.

func (*Discoverer) InvalidateCache

func (d *Discoverer) InvalidateCache()

InvalidateCache clears the discovery cache.

type DiscoveryCache

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

DiscoveryCache caches discovery results with TTL.

func NewDiscoveryCache

func NewDiscoveryCache(ttl time.Duration) *DiscoveryCache

NewDiscoveryCache creates a new discovery cache.

func (*DiscoveryCache) Get

func (c *DiscoveryCache) Get() *DiscoveryResult

Get retrieves cached result if still valid.

func (*DiscoveryCache) Invalidate

func (c *DiscoveryCache) Invalidate()

Invalidate clears the cache.

func (*DiscoveryCache) Set

func (c *DiscoveryCache) Set(result *DiscoveryResult)

Set stores a discovery result in cache.

type DiscoveryResult

type DiscoveryResult struct {
	Files        []*DiscoveredFile
	TotalSize    int64
	FilesSkipped int
	Reason       string // Reason for skipping files (if any)
}

DiscoveryResult contains the results of context discovery.

type GitignoreFilter

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

GitignoreFilter handles gitignore pattern matching.

func NewGitignoreFilter

func NewGitignoreFilter(basePath string) (*GitignoreFilter, error)

NewGitignoreFilter creates a new gitignore filter.

func (*GitignoreFilter) IsIgnored

func (g *GitignoreFilter) IsIgnored(relPath string) bool

IsIgnored checks if a file path should be ignored.

Jump to

Keyboard shortcuts

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