Documentation
¶
Index ¶
- Constants
- Variables
- func BytesToFloat32(data []byte) []float32
- func CosineSimilarity(a, b []float32) float64
- func Float32ToBytes(data []float32) []byte
- func IsMinified(path string) bool
- func ShouldIndex(path string) bool
- func WalkRepo(repoPath string, ignoreDirs ...map[string]bool) ([]string, error)
- type Chunk
- type IndexStats
- type Indexer
- type ProgressFunc
- type SearchResult
- type WalkResult
Constants ¶
const ( DefaultChunkSize = 50 // lines per chunk MaxChunkSize = 100 // absolute max lines per chunk MaxChunkBytes = 24000 // ~6000 tokens at ~4 bytes/token; well under 8192 token context )
Variables ¶
var DefaultIgnoreDirs = map[string]bool{ ".git": true, ".sl": true, "node_modules": true, "vendor": true, ".next": true, "dist": true, "build": true, "__pycache__": true, ".cache": true, "target": true, "package-lock.json": true, "yarn.lock": true, "pnpm-lock.yaml": true, "go.sum": true, "Cargo.lock": true, ".env": true, }
DefaultIgnoreDirs are directories and files skipped when no ignore set is provided. This is the fallback when no config is loaded; the config's DefaultIndexIgnore is authoritative.
Functions ¶
func BytesToFloat32 ¶
BytesToFloat32 converts a byte slice to a float32 slice. The byte slice must have length divisible by 4.
func CosineSimilarity ¶
CosineSimilarity computes the cosine similarity between two vectors.
func Float32ToBytes ¶
Float32ToBytes converts a float32 slice to a byte slice.
func IsMinified ¶
IsMinified returns true if the file appears to be minified/bundled, based on filename patterns or content sampling (avg line length > 500).
func ShouldIndex ¶
ShouldIndex returns true if the file should be indexed.
Types ¶
type Chunk ¶
type Chunk struct {
Repo string `json:"repo"`
File string `json:"file"`
Index int `json:"index"`
LineStart int `json:"line_start"`
LineEnd int `json:"line_end"`
Content string `json:"content"`
}
Chunk represents a piece of a source file.
type IndexStats ¶
type IndexStats struct {
Indexed int
Unchanged int
SkippedMinified []string // files skipped because they are minified
}
IndexStats tracks what happened during indexing.
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer builds and maintains the semantic index.
func NewIndexer ¶
NewIndexer creates a new indexer.
func (*Indexer) SetIgnoreDirs ¶
SetIgnoreDirs sets the directories to skip during indexing.
func (*Indexer) SetProgress ¶
func (idx *Indexer) SetProgress(fn ProgressFunc)
SetProgress sets the progress callback.
type ProgressFunc ¶
ProgressFunc is called during indexing to report progress. current is the file number being processed, total is the total file count, file is the relative path of the current file.
type SearchResult ¶
type SearchResult struct {
Repo string `json:"repo"`
File string `json:"file"`
LineStart int `json:"line_start"`
LineEnd int `json:"line_end"`
Score float64 `json:"score"`
Content string `json:"content,omitempty"`
}
SearchResult represents a search hit.
func RankResults ¶
func RankResults(results []SearchResult, limit int) []SearchResult
RankResults sorts search results by score descending and returns top-k.
type WalkResult ¶
WalkResult contains the results of walking a repo directory.
func WalkRepoDetailed ¶
func WalkRepoDetailed(repoPath string, ignoreDirs ...map[string]bool) (WalkResult, error)
WalkRepoDetailed walks a repo directory and returns detailed results including skips.