vectorstore

package
v0.59.5 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultStorePath is the default path for vector storage
	DefaultStorePath = ".mcp-devtools/embeddings"
	// CollectionName is the name of the chromem collection
	CollectionName = "code-search"
)

Variables

This section is empty.

Functions

func GenerateItemID

func GenerateItemID(path, name string, line int) string

GenerateItemID generates a unique ID for an item

Types

type ClearResult

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

ClearResult represents the result of a clear operation

type Item

type Item struct {
	ID        string    `json:"id"`
	Path      string    `json:"path"`
	Name      string    `json:"name"`
	Type      string    `json:"type"`
	Signature string    `json:"signature"`
	Line      int       `json:"line"`
	Embedding []float32 `json:"embedding"`
}

Item represents an indexed item with its embedding

type SearchResult

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

SearchResult represents a search result with similarity score

type StatusResult

type StatusResult struct {
	Indexed        bool     `json:"indexed"`
	TotalFiles     int      `json:"total_files"`
	TotalItems     int      `json:"total_items"`
	IndexedPaths   []string `json:"indexed_paths,omitempty"`
	ModelLoaded    bool     `json:"model_loaded"`
	ModelPath      string   `json:"model_path,omitempty"`
	RuntimeLoaded  bool     `json:"runtime_loaded"`
	RuntimeVersion string   `json:"runtime_version,omitempty"`
}

StatusResult represents the store status

type Store

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

Store provides vector storage and similarity search using chromem-go

func NewStore

func NewStore(logger *logrus.Logger) (*Store, error)

NewStore creates a new vector store with chromem-go persistence

func (*Store) Add

func (s *Store) Add(item *Item) error

Add adds an item to the store

func (*Store) AddBatch

func (s *Store) AddBatch(items []*Item) error

AddBatch adds multiple items to the store

func (*Store) Clear

func (s *Store) Clear(filterPaths []string) (*ClearResult, error)

Clear removes items from the store

func (*Store) Count

func (s *Store) Count() int

Count returns the number of indexed items

func (*Store) IsFileIndexed

func (s *Store) IsFileIndexed(path string) bool

IsFileIndexed checks if a file is already indexed

func (*Store) Save

func (s *Store) Save() error

Save persists the store to disk

func (*Store) Search

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

Search performs similarity search. Returns results, total matches (before limit), and error.

func (*Store) Status

func (s *Store) Status() *StatusResult

Status returns the current store status

func (*Store) StorePath

func (s *Store) StorePath() string

StorePath returns the path to the store directory

Jump to

Keyboard shortcuts

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