Documentation
¶
Overview ¶
Package code provides tree-sitter based code indexing with semantic search.
Package code provides code indexing with tree-sitter and semantic search.
Index ¶
- Constants
- type CodeFile
- type CodeIndexer
- func (c *CodeIndexer) FindReferences(ctx context.Context, projectID, symbolID, symbolName string, limit int) ([]*CodeSymbol, error)
- func (c *CodeIndexer) FindSymbol(ctx context.Context, query SymbolQuery) ([]*CodeSymbol, error)
- func (c *CodeIndexer) GetFileSymbols(ctx context.Context, projectID, filePath string, includeBody bool) ([]*CodeSymbol, error)
- func (c *CodeIndexer) GetJob(jobID string) (*IndexingJob, bool)
- func (c *CodeIndexer) GetProjectStats(ctx context.Context, projectID string) (map[string]interface{}, error)
- func (c *CodeIndexer) GetSymbolsOverview(ctx context.Context, projectID, filePath string, maxResults int) ([]*CodeSymbol, error)
- func (c *CodeIndexer) HybridSearch(ctx context.Context, projectID, query string, limit int, langs []Language, ...) ([]HybridSearchResult, error)
- func (c *CodeIndexer) IndexProject(ctx context.Context, projectID, projectPath string, languages []Language) (string, error)
- func (c *CodeIndexer) ListProjects(ctx context.Context) ([]*CodeProject, error)
- func (c *CodeIndexer) ReindexFile(ctx context.Context, projectID, filePath string) error
- func (c *CodeIndexer) SearchPattern(ctx context.Context, projectID, pattern string, caseSensitive bool, ...) ([]*CodeSymbol, error)
- type CodeProject
- type CodeSymbol
- type HybridSearchResult
- type IndexingJob
- type IndexingStatus
- type Language
- type ParseResult
- type SemanticSearchQuery
- type SemanticSearchResult
- type SymbolQuery
- type SymbolType
Constants ¶
const ( IndexingStatusPending = treesitter.IndexingStatusPending IndexingStatusInProgress = treesitter.IndexingStatusInProgress IndexingStatusCompleted = treesitter.IndexingStatusCompleted IndexingStatusFailed = treesitter.IndexingStatusFailed IndexingStatusCancelled = treesitter.IndexingStatusCancelled )
Re-export constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodeIndexer ¶
type CodeIndexer struct {
// contains filtered or unexported fields
}
CodeIndexer manages code indexing projects using tree-sitter for parsing and embeddings for semantic search.
func NewCodeIndexer ¶
func NewCodeIndexer(db *sql.DB, embedder embeddings.Embedder, workers int) *CodeIndexer
NewCodeIndexer creates a new CodeIndexer with the given number of concurrent workers. If workers is <= 0, the defaultWorkers value is used.
func (*CodeIndexer) FindReferences ¶
func (c *CodeIndexer) FindReferences(ctx context.Context, projectID, symbolID, symbolName string, limit int) ([]*CodeSymbol, error)
FindReferences finds all symbols that reference the given symbol by name.
func (*CodeIndexer) FindSymbol ¶
func (c *CodeIndexer) FindSymbol(ctx context.Context, query SymbolQuery) ([]*CodeSymbol, error)
FindSymbol finds symbols matching the given query criteria.
func (*CodeIndexer) GetFileSymbols ¶
func (c *CodeIndexer) GetFileSymbols(ctx context.Context, projectID, filePath string, includeBody bool) ([]*CodeSymbol, error)
GetFileSymbols returns all symbols for a file.
func (*CodeIndexer) GetJob ¶
func (c *CodeIndexer) GetJob(jobID string) (*IndexingJob, bool)
GetJob returns the current status of an indexing job.
func (*CodeIndexer) GetProjectStats ¶
func (c *CodeIndexer) GetProjectStats(ctx context.Context, projectID string) (map[string]interface{}, error)
GetProjectStats returns statistics for a project.
func (*CodeIndexer) GetSymbolsOverview ¶
func (c *CodeIndexer) GetSymbolsOverview(ctx context.Context, projectID, filePath string, maxResults int) ([]*CodeSymbol, error)
GetSymbolsOverview returns a high-level overview of symbols in a file.
func (*CodeIndexer) HybridSearch ¶
func (c *CodeIndexer) HybridSearch(ctx context.Context, projectID, query string, limit int, langs []Language, symbolTypes []SymbolType) ([]HybridSearchResult, error)
HybridSearch performs hybrid vector + FTS search over code symbols.
func (*CodeIndexer) IndexProject ¶
func (c *CodeIndexer) IndexProject(ctx context.Context, projectID, projectPath string, languages []Language) (string, error)
IndexProject indexes all supported source files in a project directory. It runs asynchronously and updates the job status in the jobs map. Returns the job ID immediately.
func (*CodeIndexer) ListProjects ¶
func (c *CodeIndexer) ListProjects(ctx context.Context) ([]*CodeProject, error)
ListProjects returns all indexed projects.
func (*CodeIndexer) ReindexFile ¶
func (c *CodeIndexer) ReindexFile(ctx context.Context, projectID, filePath string) error
ReindexFile re-indexes a single file in a project.
func (*CodeIndexer) SearchPattern ¶
func (c *CodeIndexer) SearchPattern(ctx context.Context, projectID, pattern string, caseSensitive bool, isRegex bool, limit int, langs []Language, symbolTypes []SymbolType) ([]*CodeSymbol, error)
SearchPattern searches for text patterns in code symbols.
type CodeProject ¶
type CodeProject = treesitter.CodeProject
Re-export treesitter types for convenience
type CodeSymbol ¶
type CodeSymbol = treesitter.CodeSymbol
Re-export treesitter types for convenience
type HybridSearchResult ¶
type HybridSearchResult struct {
Symbol *CodeSymbol `json:"symbol"`
Score float64 `json:"score"`
VectorScore float64 `json:"vector_score,omitempty"`
FTSScore float64 `json:"fts_score,omitempty"`
Rank int `json:"rank"`
}
HybridSearchResult represents a result from hybrid search
type IndexingJob ¶
type IndexingJob = treesitter.IndexingJob
Re-export treesitter types for convenience
type IndexingStatus ¶
type IndexingStatus = treesitter.IndexingStatus
Re-export treesitter types for convenience
type ParseResult ¶
type ParseResult = treesitter.ParseResult
Re-export treesitter types for convenience
type SemanticSearchQuery ¶
type SemanticSearchQuery = treesitter.SemanticSearchQuery
Re-export treesitter types for convenience
type SemanticSearchResult ¶
type SemanticSearchResult = treesitter.SemanticSearchResult
Re-export treesitter types for convenience
type SymbolQuery ¶
type SymbolQuery = treesitter.SymbolQuery
Re-export treesitter types for convenience
type SymbolType ¶
type SymbolType = treesitter.SymbolType
Re-export treesitter types for convenience