Documentation
¶
Index ¶
- func GetOrCreateProjectWithPool(ctx context.Context, pool *pgxpool.Pool, name string, localPath string, ...) (string, error)
- func NewPostgresPool(ctx context.Context, dsn string) (*pgxpool.Pool, error)
- func RunMigrations(ctx context.Context, pool *pgxpool.Pool) error
- func SanitizeCollectionName(path string) string
- type Chunk
- type Document
- type File
- type FileStats
- type FileStore
- type GOBStore
- func (s *GOBStore) Close() error
- func (s *GOBStore) DeleteByFile(ctx context.Context, filePath string) error
- func (s *GOBStore) DeleteDocument(ctx context.Context, filePath string) error
- func (s *GOBStore) GetAllChunks(ctx context.Context) ([]Chunk, error)
- func (s *GOBStore) GetChunksForFile(ctx context.Context, filePath string) ([]Chunk, error)
- func (s *GOBStore) GetDocument(ctx context.Context, filePath string) (*Document, error)
- func (s *GOBStore) GetStats(ctx context.Context) (*IndexStats, error)
- func (s *GOBStore) ListDocuments(ctx context.Context) ([]string, error)
- func (s *GOBStore) ListFilesWithStats(ctx context.Context) ([]FileStats, error)
- func (s *GOBStore) Load(ctx context.Context) error
- func (s *GOBStore) Persist(ctx context.Context) error
- func (s *GOBStore) SaveChunks(ctx context.Context, chunks []Chunk) error
- func (s *GOBStore) SaveDocument(ctx context.Context, doc Document) error
- func (s *GOBStore) Search(ctx context.Context, queryVector []float32, limit int) ([]SearchResult, error)
- func (s *GOBStore) Stats() (numDocs int, numChunks int)
- type IndexStats
- type IndexStatus
- type PostgresProjectStore
- func (s *PostgresProjectStore) CreateFile(ctx context.Context, f *File) error
- func (s *PostgresProjectStore) CreateProject(ctx context.Context, p *Project) error
- func (s *PostgresProjectStore) DeleteFile(ctx context.Context, projectID, relativePath string) error
- func (s *PostgresProjectStore) DeleteFilesByProject(ctx context.Context, projectID string) error
- func (s *PostgresProjectStore) DeleteProject(ctx context.Context, name string) error
- func (s *PostgresProjectStore) GetFile(ctx context.Context, projectID, relativePath string) (*File, error)
- func (s *PostgresProjectStore) GetOrCreateProject(ctx context.Context, name, localPath string) (*Project, error)
- func (s *PostgresProjectStore) GetProject(ctx context.Context, name string) (*Project, error)
- func (s *PostgresProjectStore) GetProjectByID(ctx context.Context, id string) (*Project, error)
- func (s *PostgresProjectStore) ListFiles(ctx context.Context, projectID string) ([]*File, error)
- func (s *PostgresProjectStore) ListProjects(ctx context.Context) ([]*Project, error)
- func (s *PostgresProjectStore) SetProjectStatus(ctx context.Context, name string, status IndexStatus, lastError string) error
- func (s *PostgresProjectStore) UpdateFile(ctx context.Context, f *File) error
- func (s *PostgresProjectStore) UpdateProject(ctx context.Context, p *Project) error
- func (s *PostgresProjectStore) UpdateProjectStats(ctx context.Context, name string) error
- type PostgresStore
- func (s *PostgresStore) Close() error
- func (s *PostgresStore) DeleteByFile(ctx context.Context, filePath string) error
- func (s *PostgresStore) DeleteDocument(ctx context.Context, filePath string) error
- func (s *PostgresStore) GetAllChunks(ctx context.Context) ([]Chunk, error)
- func (s *PostgresStore) GetChunksForFile(ctx context.Context, filePath string) ([]Chunk, error)
- func (s *PostgresStore) GetDocument(ctx context.Context, filePath string) (*Document, error)
- func (s *PostgresStore) GetOrCreateProject(ctx context.Context, name string, localPath string, projectID string) (string, error)
- func (s *PostgresStore) GetStats(ctx context.Context) (*IndexStats, error)
- func (s *PostgresStore) ListDocuments(ctx context.Context) ([]string, error)
- func (s *PostgresStore) ListFilesWithStats(ctx context.Context) ([]FileStats, error)
- func (s *PostgresStore) Load(ctx context.Context) error
- func (s *PostgresStore) Persist(ctx context.Context) error
- func (s *PostgresStore) Pool() *pgxpool.Pool
- func (s *PostgresStore) SaveChunks(ctx context.Context, chunks []Chunk) error
- func (s *PostgresStore) SaveDocument(ctx context.Context, doc Document) error
- func (s *PostgresStore) Search(ctx context.Context, queryVector []float32, limit int) ([]SearchResult, error)
- func (s *PostgresStore) UpdateProjectStats(ctx context.Context, projectUUID string) error
- type Project
- type ProjectStore
- type QdrantStore
- func (s *QdrantStore) Close() error
- func (s *QdrantStore) DeleteByFile(ctx context.Context, filePath string) error
- func (s *QdrantStore) DeleteDocument(ctx context.Context, filePath string) error
- func (s *QdrantStore) GetAllChunks(ctx context.Context) ([]Chunk, error)
- func (s *QdrantStore) GetChunksForFile(ctx context.Context, filePath string) ([]Chunk, error)
- func (s *QdrantStore) GetDocument(ctx context.Context, filePath string) (*Document, error)
- func (s *QdrantStore) GetStats(ctx context.Context) (*IndexStats, error)
- func (s *QdrantStore) ListDocuments(ctx context.Context) ([]string, error)
- func (s *QdrantStore) ListFilesWithStats(ctx context.Context) ([]FileStats, error)
- func (s *QdrantStore) Load(ctx context.Context) error
- func (s *QdrantStore) Persist(ctx context.Context) error
- func (s *QdrantStore) SaveChunks(ctx context.Context, chunks []Chunk) error
- func (s *QdrantStore) SaveDocument(ctx context.Context, doc Document) error
- func (s *QdrantStore) Search(ctx context.Context, queryVector []float32, limit int) ([]SearchResult, error)
- type SearchResult
- type VectorStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOrCreateProjectWithPool ¶
func GetOrCreateProjectWithPool(ctx context.Context, pool *pgxpool.Pool, name string, localPath string, projectID string) (string, error)
GetOrCreateProjectWithPool finds or creates a project using a raw pool connection. This is useful when you need to register a project before creating a PostgresStore. If projectID is provided, it will be used for new projects instead of generating one.
func NewPostgresPool ¶
NewPostgresPool creates a new connection pool without initializing a full store. This is useful for operations that need database access before store creation.
func RunMigrations ¶
RunMigrations executes all pending SQL migrations in order. Migrations are embedded from the migrations/ directory.
func SanitizeCollectionName ¶
Types ¶
type Chunk ¶
type Chunk struct {
ID string `json:"id"`
FilePath string `json:"file_path"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
Content string `json:"content"`
Vector []float32 `json:"vector"`
Hash string `json:"hash"`
UpdatedAt time.Time `json:"updated_at"`
}
Chunk represents a piece of code with its vector embedding
type Document ¶
type Document struct {
Path string `json:"path"`
Hash string `json:"hash"`
ModTime time.Time `json:"mod_time"`
ChunkIDs []string `json:"chunk_ids"`
}
Document represents a file with its chunks
type File ¶
type File struct {
ID string `json:"id"`
ProjectID string `json:"project_id"`
RelativePath string `json:"relative_path"`
Language string `json:"language,omitempty"`
ContentHash string `json:"content_hash"`
LineCount int `json:"line_count"`
ModTime time.Time `json:"mod_time"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
File represents a file within a project.
type FileStats ¶
type FileStats struct {
Path string `json:"path"`
ChunkCount int `json:"chunk_count"`
ModTime time.Time `json:"mod_time"`
}
FileStats contains statistics for a single file
type FileStore ¶
type FileStore interface {
// CreateFile creates a new file record.
CreateFile(ctx context.Context, f *File) error
// GetFile retrieves a file by project ID and relative path.
GetFile(ctx context.Context, projectID, relativePath string) (*File, error)
// UpdateFile updates an existing file record.
UpdateFile(ctx context.Context, f *File) error
// DeleteFile removes a file record.
DeleteFile(ctx context.Context, projectID, relativePath string) error
// ListFiles returns all files for a project.
ListFiles(ctx context.Context, projectID string) ([]*File, error)
// DeleteFilesByProject removes all files for a project.
DeleteFilesByProject(ctx context.Context, projectID string) error
}
FileStore defines the interface for file management operations.
type GOBStore ¶
type GOBStore struct {
// contains filtered or unexported fields
}
func NewGOBStore ¶
func (*GOBStore) DeleteByFile ¶
func (*GOBStore) DeleteDocument ¶
func (*GOBStore) GetAllChunks ¶
func (*GOBStore) GetChunksForFile ¶
func (*GOBStore) GetDocument ¶
func (*GOBStore) ListDocuments ¶
func (*GOBStore) ListFilesWithStats ¶
func (*GOBStore) SaveChunks ¶
func (*GOBStore) SaveDocument ¶
type IndexStats ¶
type IndexStats struct {
TotalFiles int `json:"total_files"`
TotalChunks int `json:"total_chunks"`
IndexSize int64 `json:"index_size"` // bytes
LastUpdated time.Time `json:"last_updated"`
}
IndexStats contains statistics about the index
type IndexStatus ¶
type IndexStatus string
IndexStatus represents the current indexing state of a project.
const ( IndexStatusPending IndexStatus = "pending" IndexStatusIndexing IndexStatus = "indexing" IndexStatusReady IndexStatus = "ready" IndexStatusError IndexStatus = "error" )
type PostgresProjectStore ¶
type PostgresProjectStore struct {
// contains filtered or unexported fields
}
PostgresProjectStore implements ProjectStore and FileStore for PostgreSQL.
func NewPostgresProjectStore ¶
func NewPostgresProjectStore(pool *pgxpool.Pool) *PostgresProjectStore
NewPostgresProjectStore creates a new PostgresProjectStore.
func (*PostgresProjectStore) CreateFile ¶
func (s *PostgresProjectStore) CreateFile(ctx context.Context, f *File) error
CreateFile creates a new file record.
func (*PostgresProjectStore) CreateProject ¶
func (s *PostgresProjectStore) CreateProject(ctx context.Context, p *Project) error
CreateProject creates a new project in the store.
func (*PostgresProjectStore) DeleteFile ¶
func (s *PostgresProjectStore) DeleteFile(ctx context.Context, projectID, relativePath string) error
DeleteFile removes a file record.
func (*PostgresProjectStore) DeleteFilesByProject ¶
func (s *PostgresProjectStore) DeleteFilesByProject(ctx context.Context, projectID string) error
DeleteFilesByProject removes all files for a project.
func (*PostgresProjectStore) DeleteProject ¶
func (s *PostgresProjectStore) DeleteProject(ctx context.Context, name string) error
DeleteProject removes a project and all its associated data.
func (*PostgresProjectStore) GetFile ¶
func (s *PostgresProjectStore) GetFile(ctx context.Context, projectID, relativePath string) (*File, error)
GetFile retrieves a file by project ID and relative path.
func (*PostgresProjectStore) GetOrCreateProject ¶
func (s *PostgresProjectStore) GetOrCreateProject(ctx context.Context, name, localPath string) (*Project, error)
GetOrCreateProject retrieves a project by name or creates it if it doesn't exist.
func (*PostgresProjectStore) GetProject ¶
GetProject retrieves a project by its name.
func (*PostgresProjectStore) GetProjectByID ¶
GetProjectByID retrieves a project by its ID.
func (*PostgresProjectStore) ListProjects ¶
func (s *PostgresProjectStore) ListProjects(ctx context.Context) ([]*Project, error)
ListProjects returns all projects in the store.
func (*PostgresProjectStore) SetProjectStatus ¶
func (s *PostgresProjectStore) SetProjectStatus(ctx context.Context, name string, status IndexStatus, lastError string) error
SetProjectStatus updates the index status and optional error message.
func (*PostgresProjectStore) UpdateFile ¶
func (s *PostgresProjectStore) UpdateFile(ctx context.Context, f *File) error
UpdateFile updates an existing file record.
func (*PostgresProjectStore) UpdateProject ¶
func (s *PostgresProjectStore) UpdateProject(ctx context.Context, p *Project) error
UpdateProject updates an existing project.
func (*PostgresProjectStore) UpdateProjectStats ¶
func (s *PostgresProjectStore) UpdateProjectStats(ctx context.Context, name string) error
UpdateProjectStats recalculates and updates project statistics.
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
func NewPostgresStore ¶
func (*PostgresStore) Close ¶
func (s *PostgresStore) Close() error
func (*PostgresStore) DeleteByFile ¶
func (s *PostgresStore) DeleteByFile(ctx context.Context, filePath string) error
func (*PostgresStore) DeleteDocument ¶
func (s *PostgresStore) DeleteDocument(ctx context.Context, filePath string) error
func (*PostgresStore) GetAllChunks ¶
func (s *PostgresStore) GetAllChunks(ctx context.Context) ([]Chunk, error)
func (*PostgresStore) GetChunksForFile ¶
func (*PostgresStore) GetDocument ¶
func (*PostgresStore) GetOrCreateProject ¶
func (s *PostgresStore) GetOrCreateProject(ctx context.Context, name string, localPath string, projectID string) (string, error)
GetOrCreateProject finds a project by name or creates it if not found. If the project exists but local_path differs, it updates the path. If projectID is provided, it will be used for new projects instead of generating one. Returns the project UUID.
func (*PostgresStore) GetStats ¶
func (s *PostgresStore) GetStats(ctx context.Context) (*IndexStats, error)
func (*PostgresStore) ListDocuments ¶
func (s *PostgresStore) ListDocuments(ctx context.Context) ([]string, error)
func (*PostgresStore) ListFilesWithStats ¶
func (s *PostgresStore) ListFilesWithStats(ctx context.Context) ([]FileStats, error)
func (*PostgresStore) Pool ¶
func (s *PostgresStore) Pool() *pgxpool.Pool
Pool returns the underlying connection pool for use by other stores.
func (*PostgresStore) SaveChunks ¶
func (s *PostgresStore) SaveChunks(ctx context.Context, chunks []Chunk) error
func (*PostgresStore) SaveDocument ¶
func (s *PostgresStore) SaveDocument(ctx context.Context, doc Document) error
func (*PostgresStore) Search ¶
func (s *PostgresStore) Search(ctx context.Context, queryVector []float32, limit int) ([]SearchResult, error)
func (*PostgresStore) UpdateProjectStats ¶
func (s *PostgresStore) UpdateProjectStats(ctx context.Context, projectUUID string) error
UpdateProjectStats updates file_count, chunk_count, and sets status to 'ready'.
type Project ¶
type Project struct {
ID string `json:"id"`
Name string `json:"name"`
LocalPath string `json:"local_path,omitempty"`
Languages []string `json:"languages,omitempty"`
Framework string `json:"framework,omitempty"`
FileCount int `json:"file_count"`
ChunkCount int `json:"chunk_count"`
SymbolCount int `json:"symbol_count"`
IndexStatus IndexStatus `json:"index_status"`
LastError string `json:"last_error,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
LastIndexedAt *time.Time `json:"last_indexed_at,omitempty"`
}
Project represents a code project in the system.
type ProjectStore ¶
type ProjectStore interface {
// CreateProject creates a new project in the store.
CreateProject(ctx context.Context, p *Project) error
// GetProject retrieves a project by its name.
GetProject(ctx context.Context, name string) (*Project, error)
// GetProjectByID retrieves a project by its ID.
GetProjectByID(ctx context.Context, id string) (*Project, error)
// UpdateProject updates an existing project.
UpdateProject(ctx context.Context, p *Project) error
// DeleteProject removes a project and all its associated data.
DeleteProject(ctx context.Context, name string) error
// ListProjects returns all projects in the store.
ListProjects(ctx context.Context) ([]*Project, error)
// UpdateProjectStats recalculates and updates project statistics.
UpdateProjectStats(ctx context.Context, name string) error
// SetProjectStatus updates the index status and optional error message.
SetProjectStatus(ctx context.Context, name string, status IndexStatus, lastError string) error
}
ProjectStore defines the interface for project management operations.
type QdrantStore ¶
type QdrantStore struct {
// contains filtered or unexported fields
}
func NewQdrantStore ¶
func (*QdrantStore) Close ¶
func (s *QdrantStore) Close() error
func (*QdrantStore) DeleteByFile ¶
func (s *QdrantStore) DeleteByFile(ctx context.Context, filePath string) error
func (*QdrantStore) DeleteDocument ¶
func (s *QdrantStore) DeleteDocument(ctx context.Context, filePath string) error
func (*QdrantStore) GetAllChunks ¶
func (s *QdrantStore) GetAllChunks(ctx context.Context) ([]Chunk, error)
func (*QdrantStore) GetChunksForFile ¶
func (*QdrantStore) GetDocument ¶
func (*QdrantStore) GetStats ¶
func (s *QdrantStore) GetStats(ctx context.Context) (*IndexStats, error)
func (*QdrantStore) ListDocuments ¶
func (s *QdrantStore) ListDocuments(ctx context.Context) ([]string, error)
func (*QdrantStore) ListFilesWithStats ¶
func (s *QdrantStore) ListFilesWithStats(ctx context.Context) ([]FileStats, error)
func (*QdrantStore) SaveChunks ¶
func (s *QdrantStore) SaveChunks(ctx context.Context, chunks []Chunk) error
func (*QdrantStore) SaveDocument ¶
func (s *QdrantStore) SaveDocument(ctx context.Context, doc Document) error
func (*QdrantStore) Search ¶
func (s *QdrantStore) Search(ctx context.Context, queryVector []float32, limit int) ([]SearchResult, error)
type SearchResult ¶
SearchResult represents a search match with its relevance score
type VectorStore ¶
type VectorStore interface {
// SaveChunks stores multiple chunks atomically
SaveChunks(ctx context.Context, chunks []Chunk) error
// DeleteByFile removes all chunks for a given file path
DeleteByFile(ctx context.Context, filePath string) error
// Search finds the most similar chunks to a query vector
Search(ctx context.Context, queryVector []float32, limit int) ([]SearchResult, error)
// GetDocument retrieves document metadata by path
GetDocument(ctx context.Context, filePath string) (*Document, error)
// SaveDocument stores document metadata
SaveDocument(ctx context.Context, doc Document) error
// DeleteDocument removes document metadata
DeleteDocument(ctx context.Context, filePath string) error
// ListDocuments returns all indexed document paths
ListDocuments(ctx context.Context) ([]string, error)
// Load reads the store from persistent storage
Load(ctx context.Context) error
// Persist writes the store to persistent storage
Persist(ctx context.Context) error
// Close cleanly shuts down the store
Close() error
// GetStats returns index statistics
GetStats(ctx context.Context) (*IndexStats, error)
// ListFilesWithStats returns all files with their chunk counts
ListFilesWithStats(ctx context.Context) ([]FileStats, error)
// GetChunksForFile returns all chunks for a specific file
GetChunksForFile(ctx context.Context, filePath string) ([]Chunk, error)
// GetAllChunks returns all chunks in the store (used for text search)
GetAllChunks(ctx context.Context) ([]Chunk, error)
}
VectorStore defines the interface for vector storage backends