context

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxFileSize is the maximum size of a referenced file to include
	MaxFileSize = 10000
	// MaxTotalContextSize is the maximum total context from referenced files
	MaxTotalContextSize = 50000
	// MaxFilesToFetch is the maximum number of referenced files to fetch
	MaxFilesToFetch = 10
)
View Source
const (
	// StabilityThresholdDays - files not modified in this many days are considered stable
	StabilityThresholdDays = 30
)

Variables

This section is empty.

Functions

func FormatBlameContext

func FormatBlameContext(files map[string]string) string

FormatBlameContext formats blame information for inclusion in the prompt

func FormatForLLM

func FormatForLLM(files []FetchedFile) string

FormatForLLM formats fetched files for inclusion in the LLM prompt

func GetChangedLineNumbers

func GetChangedLineNumbers(lines []struct {
	Type   int // 0=context, 1=added, 2=removed
	NewNum int
}) []int

GetChangedLineNumbers extracts line numbers that were modified from a hunk

func GetFileBlameContext

func GetFileBlameContext(filename string, changedLines []int) string

GetFileBlameContext gets blame context for a file diff

func GetFileStability

func GetFileStability(filename string) (stable bool, commitCount int, err error)

GetFileStability determines if a file is stable (not frequently changed)

func GetLogForFile

func GetLogForFile(filename string, limit int) ([]string, error)

GetLogForFile gets recent commit history for a file

Types

type BlameInfo

type BlameInfo struct {
	Filename     string
	LastModified time.Time
	Authors      []string
	AgeInDays    int
	IsStable     bool // True if not modified recently
}

BlameInfo contains git blame information for a file

func GetBlameInfo

func GetBlameInfo(filename string, startLine, endLine int) (*BlameInfo, error)

GetBlameInfo runs git blame and extracts information about a file

type BlameLineInfo

type BlameLineInfo struct {
	Author    string
	Email     string
	Timestamp time.Time
	Commit    string
}

BlameLineInfo contains blame info for a specific line

type FetchedFile

type FetchedFile struct {
	Path     string
	Content  string
	Language string
	Size     int
}

FetchedFile represents a file that was fetched for context

type Fetcher

type Fetcher struct {
	RootDir  string
	Resolver *Resolver
}

Fetcher fetches referenced files for context expansion

func NewFetcher

func NewFetcher(rootDir string) *Fetcher

NewFetcher creates a new context fetcher

func (*Fetcher) FetchReferencedFiles

func (f *Fetcher) FetchReferencedFiles(files []diff.FileDiff) []FetchedFile

FetchReferencedFiles extracts imports from changed files and fetches their content

type ImportInfo

type ImportInfo struct {
	Source       string // The file containing the import
	ImportPath   string // The imported path
	ResolvedPath string // The resolved local file path
	Language     string // The detected language
}

ImportInfo represents an import statement found in a file

type Resolver

type Resolver struct {
	RootDir string
}

Resolver resolves imports from code files to their local paths

func NewResolver

func NewResolver(rootDir string) *Resolver

NewResolver creates a new import resolver

func (*Resolver) ExtractImports

func (r *Resolver) ExtractImports(filename, content string) []ImportInfo

ExtractImports extracts imports from file content based on language

Jump to

Keyboard shortcuts

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