efie

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ExternalNode = "__external__"

ExternalNode is the sentinel path for unresolved/external imports.

Variables

This section is empty.

Functions

func ComputeApproxBetweenness

func ComputeApproxBetweenness(g *WeightedImportGraph, sampleSize int, seed int64) map[string]float64

ComputeApproxBetweenness computes approximate betweenness centrality using stratified random sampling.

func ComputePageRank

func ComputePageRank(g *WeightedImportGraph, iterations int, damping float64) map[string]float64

ComputePageRank computes the stationary distribution probability for each node.

func ComputePercentile

func ComputePercentile(values []float64, p float64) float64

ComputePercentile returns the p-th percentile of the values.

func IsExported

func IsExported(name string, language string) bool

IsExported reports whether a symbol name is exported in its language.

func LouvainDetect_Deterministic

func LouvainDetect_Deterministic(g *WeightedImportGraph, seed int64) map[string]int

LouvainDetect_Deterministic runs one-pass Louvain community detection with a fixed seed for reproducible output.

Types

type BloomFilter

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

BloomFilter provides O(1) probabilistic membership tests.

func NewBloomFilter

func NewBloomFilter(expectedItems int, fpRate float64) *BloomFilter

NewBloomFilter creates a bloom filter for expectedItems with the given false positive rate. ~1.2 bytes per element at 1% FP rate.

func (*BloomFilter) Add

func (bf *BloomFilter) Add(item string)

Add inserts an item into the bloom filter.

func (*BloomFilter) Contains

func (bf *BloomFilter) Contains(item string) bool

Contains returns true if the item is probably in the set, false if definitely not. O(1) time.

type EFIEIndex

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

EFIEIndex is the main EFIE index containing the graph and multi-resolution index.

func NewEFIEIndex

func NewEFIEIndex(workDir string) *EFIEIndex

NewEFIEIndex creates a new EFIE index for the given working directory.

func (*EFIEIndex) Build

func (e *EFIEIndex) Build(ctx context.Context) error

Build constructs the EFIE index from source files.

func (*EFIEIndex) Communities

func (e *EFIEIndex) Communities() map[int][]string

Communities returns all communities and their members.

func (*EFIEIndex) CommunityOf

func (e *EFIEIndex) CommunityOf(path string) int

CommunityOf returns the community ID for a file.

func (*EFIEIndex) Define

func (e *EFIEIndex) Define(symbol string) []SymbolLocation

Define returns where a symbol is defined.

func (*EFIEIndex) Downstream

func (e *EFIEIndex) Downstream(path string, depth int) []string

Downstream returns files that depend on the given path.

func (*EFIEIndex) FileCount

func (e *EFIEIndex) FileCount() int

FileCount returns the number of indexed source files.

func (*EFIEIndex) FileSymbols

func (e *EFIEIndex) FileSymbols(path string) []SymbolInfo

FileSymbols returns all symbols defined in a file.

func (*EFIEIndex) FormatContext

func (e *EFIEIndex) FormatContext(targetFiles []string, description string, topN int, maxBytes int) string

FormatContext generates an LLM-ready text summary of relevant codebase intelligence.

func (*EFIEIndex) IsBuilt

func (e *EFIEIndex) IsBuilt() bool

IsBuilt reports whether the index has been built.

func (*EFIEIndex) PageRankOf

func (e *EFIEIndex) PageRankOf(path string) float64

PageRankOf returns the PageRank score for a file.

func (*EFIEIndex) ProjectSummary

func (e *EFIEIndex) ProjectSummary(maxBytes int) string

ProjectSummary returns a high-level summary of the project structure.

func (*EFIEIndex) RelevantFiles

func (e *EFIEIndex) RelevantFiles(targetFiles []string, description string, topN int) []ScoredFile

RelevantFiles returns top-N files relevant to the given targets and description.

func (*EFIEIndex) SymbolCount

func (e *EFIEIndex) SymbolCount() int

SymbolCount returns the number of unique symbols.

func (*EFIEIndex) SymbolsMatching

func (e *EFIEIndex) SymbolsMatching(query string) []string

SymbolsMatching returns symbols matching the query.

func (*EFIEIndex) Upstream

func (e *EFIEIndex) Upstream(path string, depth int) []string

Upstream returns files that the given path depends on.

type EFIEIndexer

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

EFIEIndexer wraps EFIEIndex to satisfy the codeintel.Indexer interface. This allows existing workflow code to use EFIE without modification.

func NewEFIEIndexer

func NewEFIEIndexer(workDir string) *EFIEIndexer

NewEFIEIndexer creates a new EFIE-backed indexer.

func (*EFIEIndexer) Build

func (e *EFIEIndexer) Build(ctx context.Context) error

Build constructs the EFIE index.

func (*EFIEIndexer) BuiltAt

func (e *EFIEIndexer) BuiltAt() time.Time

BuiltAt returns when the indexer was last built.

func (*EFIEIndexer) Communities

func (e *EFIEIndexer) Communities() map[int][]string

Communities returns all communities and their members.

func (*EFIEIndexer) CommunityOf

func (e *EFIEIndexer) CommunityOf(path string) int

CommunityOf returns the community ID for a file.

func (*EFIEIndexer) Define

func (e *EFIEIndexer) Define(symbol string) []SymbolLocation

Define returns where a symbol is defined.

func (*EFIEIndexer) Downstream

func (e *EFIEIndexer) Downstream(path string, depth int) []string

Downstream returns files that depend on the given path.

func (*EFIEIndexer) FileCount

func (e *EFIEIndexer) FileCount() int

FileCount returns the number of parsed source files.

func (*EFIEIndexer) FileSymbols

func (e *EFIEIndexer) FileSymbols(path string) []SymbolInfo

FileSymbols returns all symbols defined in a file.

func (*EFIEIndexer) FormatContext

func (e *EFIEIndexer) FormatContext(targetFiles []string, description string, topN int, maxBytes int) string

FormatContext generates an LLM-ready text summary.

func (*EFIEIndexer) IsBuilt

func (e *EFIEIndexer) IsBuilt() bool

IsBuilt reports whether the indexer has been built.

func (*EFIEIndexer) Neighbors

func (e *EFIEIndexer) Neighbors(path string) (imports []string, importedBy []string)

Neighbors returns direct imports and importers of a file.

func (*EFIEIndexer) PageRankOf

func (e *EFIEIndexer) PageRankOf(path string) float64

PageRankOf returns the PageRank score for a file.

func (*EFIEIndexer) ProjectSummary

func (e *EFIEIndexer) ProjectSummary(maxBytes int) string

ProjectSummary returns a high-level summary of the project structure.

func (*EFIEIndexer) RelevantFiles

func (e *EFIEIndexer) RelevantFiles(targetFiles []string, description string, topN int) []ScoredFile

RelevantFiles returns top-N files relevant to the given targets.

func (*EFIEIndexer) SymbolCount

func (e *EFIEIndexer) SymbolCount() int

SymbolCount returns the number of unique symbols.

func (*EFIEIndexer) SymbolsMatching

func (e *EFIEIndexer) SymbolsMatching(query string) []string

SymbolsMatching returns symbols matching the query.

func (*EFIEIndexer) Upstream

func (e *EFIEIndexer) Upstream(path string, depth int) []string

Upstream returns files that the given path depends on.

type FileInfo

type FileInfo struct {
	Path     string
	Language string
	Imports  []ImportInfo
	Exports  []SymbolInfo2
	Funcs    []FuncSignature
	Types    []TypeInfo
}

FileInfo is the parsed representation of a single source file.

type FuncSignature

type FuncSignature struct {
	Name     string
	Receiver string
	Params   string
	Returns  string
	Exported bool
}

FuncSignature represents a function signature.

type GoParser

type GoParser struct{}

func (*GoParser) CanParse

func (p *GoParser) CanParse(path string) bool

func (*GoParser) Language

func (p *GoParser) Language() string

func (*GoParser) Parse

func (p *GoParser) Parse(path string, content []byte) (*FileInfo, error)

type ImportInfo

type ImportInfo struct {
	Path string
}

ImportInfo represents a single import declaration.

type MultiResIndex

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

MultiResIndex provides three-level indexing: File -> Package -> Community.

func NewMultiResIndex

func NewMultiResIndex() *MultiResIndex

NewMultiResIndex creates a new empty multi-resolution index.

func (*MultiResIndex) AddFile

func (idx *MultiResIndex) AddFile(path, language string, symbols []SymbolInfo)

AddFile adds a file to the index.

func (*MultiResIndex) AllSymbols

func (idx *MultiResIndex) AllSymbols() []string

AllSymbols returns all unique symbol names.

func (*MultiResIndex) BuildTrieIndex

func (idx *MultiResIndex) BuildTrieIndex()

BuildTrieIndex builds the symbol trie from all indexed symbols.

func (*MultiResIndex) Communities

func (idx *MultiResIndex) Communities() map[int][]string

Communities returns all communities and their members.

func (*MultiResIndex) CommunityAdj

func (idx *MultiResIndex) CommunityAdj() map[int]map[int]bool

CommunityAdj returns the community adjacency map.

func (*MultiResIndex) CommunityOf

func (idx *MultiResIndex) CommunityOf(path string) int

CommunityOf returns the community ID for a file.

func (*MultiResIndex) Define

func (idx *MultiResIndex) Define(name string) []SymbolLocation

Define returns all locations where a symbol is defined.

func (*MultiResIndex) FileCount

func (idx *MultiResIndex) FileCount() int

FileCount returns the number of indexed files.

func (*MultiResIndex) FileSymbols

func (idx *MultiResIndex) FileSymbols(path string) []SymbolInfo

FileSymbols returns all symbols defined in a file.

func (*MultiResIndex) SetCentralityPercentiles

func (idx *MultiResIndex) SetCentralityPercentiles(p50, p95 float64)

SetCentralityPercentiles caches the 50th and 95th percentile centrality values.

func (*MultiResIndex) SetCommunity

func (idx *MultiResIndex) SetCommunity(path string, community int)

SetCommunity sets the community ID for a file.

func (*MultiResIndex) SetCommunityAdj

func (idx *MultiResIndex) SetCommunityAdj(adj map[int]map[int]bool)

SetCommunityAdj sets the adjacency map for communities.

func (*MultiResIndex) SetImportanceRank

func (idx *MultiResIndex) SetImportanceRank(rank []string)

SetImportanceRank sets the importance-ranked file list.

func (*MultiResIndex) SortedImportanceRank

func (idx *MultiResIndex) SortedImportanceRank() []string

SortedImportanceRank returns files sorted by PageRank descending.

func (*MultiResIndex) SymbolCount

func (idx *MultiResIndex) SymbolCount() int

SymbolCount returns the number of unique symbols.

func (*MultiResIndex) SymbolsMatching

func (idx *MultiResIndex) SymbolsMatching(query string) []string

SymbolsMatching returns symbols whose names contain the query (case-insensitive).

type Parser

type Parser interface {
	Language() string
	CanParse(path string) bool
	Parse(path string, content []byte) (*FileInfo, error)
}

Parser extracts structured information from a source file.

func AllParsers

func AllParsers() []Parser

AllParsers returns the default set of language parsers.

func ParserForFile

func ParserForFile(path string, parsers []Parser) Parser

ParserForFile returns the first parser that can handle the given file.

type PythonParser

type PythonParser struct{}

func (*PythonParser) CanParse

func (p *PythonParser) CanParse(path string) bool

func (*PythonParser) Language

func (p *PythonParser) Language() string

func (*PythonParser) Parse

func (p *PythonParser) Parse(path string, content []byte) (*FileInfo, error)

type QueryType

type QueryType string

QueryType represents the type of codebase query.

const (
	QueryRelevant   QueryType = "relevant"
	QueryUpstream   QueryType = "upstream"
	QueryDownstream QueryType = "downstream"
	QueryDefine     QueryType = "define"
	QueryReferences QueryType = "references"
)

type RustParser

type RustParser struct{}

func (*RustParser) CanParse

func (p *RustParser) CanParse(path string) bool

func (*RustParser) Language

func (p *RustParser) Language() string

func (*RustParser) Parse

func (p *RustParser) Parse(path string, content []byte) (*FileInfo, error)

type ScoredFile

type ScoredFile struct {
	Path    string
	Score   float64
	Reasons []string
}

ScoredFile represents a file ranked by relevance to a task.

func Query

func Query(efie *EFIEIndex, targetFiles []string, taskDescription string,
	queryType QueryType, topN int) []ScoredFile

Query executes an EFIE query with adaptive expansion.

func Score

func Score(file string, targets []string, description string,
	graph *WeightedImportGraph, index *MultiResIndex,
	targetCommunities map[int]bool) ScoredFile

Score computes the EFIE relevance score for a file. It combines 6 weighted components: centrality, direct relevance, import proximity, symbol match, community boost, and Bloom cross-check.

type SymbolInfo

type SymbolInfo struct {
	Name     string
	Kind     string
	Exported bool
}

SymbolInfo represents a named symbol in a file.

type SymbolInfo2

type SymbolInfo2 struct {
	Name     string
	Kind     string
	Exported bool
}

SymbolInfo2 represents a named symbol.

type SymbolLocation

type SymbolLocation struct {
	File string
	Kind string
}

SymbolLocation identifies where a symbol is defined.

type Trie

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

Trie provides O(K) prefix-based symbol search.

func BuildTrie

func BuildTrie(names []string) *Trie

BuildTrie constructs a trie from a list of symbol names.

func NewTrie

func NewTrie() *Trie

NewTrie creates a new empty trie.

func (*Trie) HasPrefix

func (t *Trie) HasPrefix(prefix string) bool

HasPrefix checks if any symbol starts with the given prefix. O(K) time.

func (*Trie) Insert

func (t *Trie) Insert(name string)

Insert adds a symbol name to the trie. O(K) time.

func (*Trie) PrefixSearch

func (t *Trie) PrefixSearch(prefix string) []string

PrefixSearch returns all symbols sharing the given prefix. O(K + M) time.

func (*Trie) Search

func (t *Trie) Search(name string) []string

Search returns exact match results. O(K) time.

type TrieNode

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

TrieNode represents a node in the trie for symbol matching.

type TypeInfo

type TypeInfo struct {
	Name    string
	Kind    string
	Fields  []string
	Methods []string
}

TypeInfo represents a type definition.

type TypeScriptParser

type TypeScriptParser struct{}

func (*TypeScriptParser) CanParse

func (p *TypeScriptParser) CanParse(path string) bool

func (*TypeScriptParser) Language

func (p *TypeScriptParser) Language() string

func (*TypeScriptParser) Parse

func (p *TypeScriptParser) Parse(path string, content []byte) (*FileInfo, error)

type WeightedImportGraph

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

WeightedImportGraph is a directed dependency graph with precomputed metrics.

func NewWeightedImportGraph

func NewWeightedImportGraph() *WeightedImportGraph

NewWeightedImportGraph creates an empty weighted import graph.

func (*WeightedImportGraph) AddNode

func (g *WeightedImportGraph) AddNode(path string, imports []string, language string)

AddNode adds a file to the graph with its imports.

func (*WeightedImportGraph) AllNodes

func (g *WeightedImportGraph) AllNodes() []*WeightedNode

AllNodes returns all nodes in the graph.

func (*WeightedImportGraph) AllPaths

func (g *WeightedImportGraph) AllPaths() []string

AllPaths returns all file paths in the graph.

func (*WeightedImportGraph) Downstream

func (g *WeightedImportGraph) Downstream(path string, depth int) []string

Downstream returns all files that depend on `path`, up to `depth` levels.

func (*WeightedImportGraph) EdgeCount

func (g *WeightedImportGraph) EdgeCount() int

EdgeCount returns the total number of directed edges.

func (*WeightedImportGraph) HasNode

func (g *WeightedImportGraph) HasNode(path string) bool

HasNode reports whether the graph contains a node for the given path.

func (*WeightedImportGraph) Neighbors

func (g *WeightedImportGraph) Neighbors(path string) (imports []string, importedBy []string)

Neighbors returns direct imports and direct importers of a file.

func (*WeightedImportGraph) NodeCount

func (g *WeightedImportGraph) NodeCount() int

NodeCount returns the number of nodes in the graph.

func (*WeightedImportGraph) RebuildEdges

func (g *WeightedImportGraph) RebuildEdges(path string, newImports []string)

RebuildEdges rebuilds edges for a single node and its neighbors.

func (*WeightedImportGraph) SetExternal

func (g *WeightedImportGraph) SetExternal(path string)

SetExternal marks the external node so it can be excluded from community detection.

func (*WeightedImportGraph) Upstream

func (g *WeightedImportGraph) Upstream(path string, depth int) []string

Upstream returns all files that `path` depends on, up to `depth` levels.

type WeightedNode

type WeightedNode struct {
	Path       string
	Imports    []string // files this file imports (direct edges)
	ImportedBy []string // files that import this file (reverse edges)

	Language string

	// Precomputed importance metrics
	PageRank         float64
	Betweenness      float64
	Community        int
	DegreeCentrality float64

	// Semantic fingerprint
	SymbolBloom *BloomFilter
	ImportSet   map[string]bool
}

WeightedNode extends a basic graph node with precomputed importance metrics.

Jump to

Keyboard shortcuts

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