codesearch

package
v0.59.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionType

type ActionType string

ActionType represents the type of action to perform

const (
	ActionSearch ActionType = "search"
	ActionIndex  ActionType = "index"
	ActionStatus ActionType = "status"
	ActionClear  ActionType = "clear"
)

type ClearResponse

type ClearResponse struct {
	Cleared      bool `json:"cleared"`
	FilesCleared int  `json:"files_cleared"`
	ItemsCleared int  `json:"items_cleared"`
}

ClearResponse represents the response from a clear action

type CodeSearchTool

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

CodeSearchTool implements the tools.Tool interface for semantic code search

func (*CodeSearchTool) Definition

func (t *CodeSearchTool) Definition() mcp.Tool

Definition returns the tool's definition for MCP registration

func (*CodeSearchTool) Execute

func (t *CodeSearchTool) Execute(ctx context.Context, logger *logrus.Logger, cache *sync.Map, args map[string]any) (*mcp.CallToolResult, error)

Execute executes the code search tool

func (*CodeSearchTool) ProvideExtendedInfo

func (t *CodeSearchTool) ProvideExtendedInfo() *tools.ExtendedHelp

ProvideExtendedInfo implements the ExtendedHelpProvider interface

type EmbeddingConfig

type EmbeddingConfig struct {
	ModelPath    string // Path to model files
	RuntimePath  string // Path to ONNX runtime library
	BatchSize    int    // Batch size for embedding generation
	MaxSeqLength int    // Maximum sequence length
}

EmbeddingConfig holds configuration for the embedding engine

func DefaultEmbeddingConfig

func DefaultEmbeddingConfig() EmbeddingConfig

DefaultEmbeddingConfig returns the default embedding configuration

type EmbeddingEngine

type EmbeddingEngine struct {
	*embedding.Engine
}

EmbeddingEngine wraps the embedding package

func NewEmbeddingEngine

func NewEmbeddingEngine(config EmbeddingConfig, logger *logrus.Logger) (*EmbeddingEngine, error)

NewEmbeddingEngine creates a new embedding engine

func (*EmbeddingEngine) Embed

func (e *EmbeddingEngine) Embed(ctx context.Context, text string) ([]float32, error)

Embed generates an embedding for text

type FileTracker

type FileTracker = filetracker.Tracker

FileTracker wraps the filetracker package

func NewFileTracker

func NewFileTracker(storePath string, logger *logrus.Logger) (*FileTracker, error)

NewFileTracker creates a new file tracker

type IndexResponse

type IndexResponse struct {
	IndexedFiles int `json:"indexed_files"`
	IndexedItems int `json:"indexed_items"`
	SkippedFiles int `json:"skipped_files,omitempty"`
}

IndexResponse represents the response from an index action

type IndexedItem

type IndexedItem struct {
	ID        string    `json:"id"`        // Unique identifier
	Path      string    `json:"path"`      // File path
	Name      string    `json:"name"`      // Function/class name
	Type      string    `json:"type"`      // "function", "method", "class"
	Signature string    `json:"signature"` // Full signature
	Line      int       `json:"line"`      // Line number
	Embedding []float32 `json:"embedding"` // Vector embedding
}

IndexedItem represents an item stored in the vector database

type Indexer

type Indexer struct {
	*index.Indexer
}

Indexer wraps the index package

func NewIndexer

func NewIndexer(embedder *EmbeddingEngine, store *VectorStore, tracker *FileTracker, logger *logrus.Logger) *Indexer

NewIndexer creates a new indexer

func (*Indexer) Index

func (i *Indexer) Index(ctx context.Context, paths []string) (*IndexResponse, error)

Index indexes the specified paths

func (*Indexer) IndexFiles

func (i *Indexer) IndexFiles(ctx context.Context, files []string) (*IndexResponse, error)

IndexFiles indexes specific files (used for reindexing stale files)

type SearchRequest

type SearchRequest struct {
	Action    ActionType `json:"action"`
	Source    []string   `json:"source,omitempty"`    // Paths for index/search/status/clear
	Query     string     `json:"query,omitempty"`     // Natural language query for search
	Limit     int        `json:"limit,omitempty"`     // Max results (default: 10)
	Threshold float64    `json:"threshold,omitempty"` // Similarity threshold (default: 0.5)
}

SearchRequest represents a request to the code_search tool

type SearchResponse

type SearchResponse struct {
	Results      []SearchResult `json:"results,omitempty"`
	TotalMatches int            `json:"total_matches,omitempty"` // Total matches before limit applied
	LimitApplied int            `json:"limit_applied,omitempty"` // Limit that was applied (only if truncated)
	LastIndexed  string         `json:"last_indexed,omitempty"`  // When index was last updated, e.g. "2025-10-23 06:30"
}

SearchResponse represents the response from a search action

type SearchResult

type SearchResult struct {
	Path       string  `json:"path"`
	Name       string  `json:"name"`
	Type       string  `json:"type"` // "function", "method", "class"
	Signature  string  `json:"signature"`
	Similarity float64 `json:"similarity"`
	Line       int     `json:"line,omitempty"`
}

SearchResult represents a single search result

type StatusResponse

type StatusResponse struct {
	Indexed        bool   `json:"indexed"`
	TotalFiles     int    `json:"total_files"`
	TotalItems     int    `json:"total_items"`
	ModelLoaded    bool   `json:"model_loaded"`
	RuntimeLoaded  bool   `json:"runtime_loaded"`
	RuntimeVersion string `json:"runtime_version,omitempty"`
}

StatusResponse represents the response from a status action

type VectorStore

type VectorStore struct {
	*vectorstore.Store
}

VectorStore wraps the vectorstore package

func NewVectorStore

func NewVectorStore(logger *logrus.Logger) (*VectorStore, error)

NewVectorStore creates a new vector store

func (*VectorStore) Clear

func (v *VectorStore) Clear(filterPaths []string) (*ClearResponse, error)

Clear clears the store

func (*VectorStore) Search

func (v *VectorStore) Search(ctx context.Context, queryEmbedding []float32, limit int, threshold float64, filterPaths []string) ([]SearchResult, int, error)

Search performs similarity search and returns SearchResult slice with total match count

func (*VectorStore) Status

func (v *VectorStore) Status() *StatusResponse

Status returns the store status

func (*VectorStore) StorePath

func (v *VectorStore) StorePath() string

StorePath returns the path to the store directory

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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