Documentation
¶
Overview ¶
Package scip provides the main service for SCIP code intelligence.
Package scip provides SCIP index storage and querying for precise code navigation.
Index ¶
- func InstallInstructions() map[string]string
- func ParseSymbol(symbol string) (scheme, pkg string, descriptors []string, isLocal bool)
- func SymbolToHumanReadable(symbol string) string
- type DefinitionResult
- type FederatedClient
- func (c *FederatedClient) FindReferences(ctx context.Context, repoName string, repoID int64, filePath string, ...) (json.RawMessage, error)
- func (c *FederatedClient) GetStats(ctx context.Context, repoName string, repoID int64) (map[string]any, error)
- func (c *FederatedClient) GoToDefinition(ctx context.Context, repoName string, repoID int64, filePath string, ...) (json.RawMessage, error)
- func (c *FederatedClient) HasIndex(ctx context.Context, repoName string, repoID int64) (bool, error)
- func (c *FederatedClient) ListFiles(ctx context.Context, repoName string, repoID int64, limit int) (json.RawMessage, error)
- func (c *FederatedClient) SearchSymbols(ctx context.Context, repoName string, repoID int64, query string, limit int) (json.RawMessage, error)
- type IndexOptions
- type IndexResult
- type Indexer
- func (i *Indexer) DetectLanguage(repoPath string) (string, error)
- func (i *Indexer) DetectLanguages(repoPath string) []string
- func (i *Indexer) GetAvailableIndexers() map[string]bool
- func (i *Indexer) Index(ctx context.Context, repoID int64, repoPath string, language string) (*IndexResult, error)
- func (i *Indexer) IndexWithOptions(ctx context.Context, repoID int64, repoPath string, language string, ...) (*IndexResult, error)
- func (i *Indexer) IsIndexerAvailable(language string) bool
- func (i *Indexer) SupportedLanguages() []string
- type IndexerConfig
- type Occurrence
- type Parser
- func (p *Parser) AppendFromBytesWithPrefix(ctx context.Context, repoID int64, data []byte, pathPrefix string) error
- func (p *Parser) ImportFromBytes(ctx context.Context, repoID int64, data []byte) error
- func (p *Parser) ImportFromBytesWithPrefix(ctx context.Context, repoID int64, data []byte, pathPrefix string) error
- func (p *Parser) ImportFromFile(ctx context.Context, repoID int64, filePath string) error
- func (p *Parser) ImportFromReader(ctx context.Context, repoID int64, r io.Reader) error
- func (p *Parser) ImportIndex(ctx context.Context, repoID int64, index *scipproto.Index) error
- func (p *Parser) ImportIndexWithPrefix(ctx context.Context, repoID int64, index *scipproto.Index, pathPrefix string) error
- type ReferencesResult
- type Service
- func (s *Service) ClearIndex(ctx context.Context, repoID int64) error
- func (s *Service) Close() error
- func (s *Service) DeleteIndex(ctx context.Context, repoID int64) error
- func (s *Service) DetectLanguage(repoPath string) (string, error)
- func (s *Service) DetectLanguages(repoPath string) []string
- func (s *Service) EvictCache(repoID int64)
- func (s *Service) FindReferences(ctx context.Context, repoID int64, filePath string, line, col int, limit int) (*ReferencesResult, error)
- func (s *Service) GetAvailableIndexers() map[string]bool
- func (s *Service) GetOccurrenceAtPosition(ctx context.Context, repoID int64, filePath string, line, col int) (*Occurrence, error)
- func (s *Service) GetStats(ctx context.Context, repoID int64) (map[string]any, error)
- func (s *Service) GetSymbolInfo(ctx context.Context, repoID int64, symbol string) (*SymbolInfo, error)
- func (s *Service) GoToDefinition(ctx context.Context, repoID int64, filePath string, line, col int) (*DefinitionResult, error)
- func (s *Service) HasIndex(ctx context.Context, repoID int64) (bool, error)
- func (s *Service) ImportFromBytes(ctx context.Context, repoID int64, data []byte) error
- func (s *Service) ImportFromFile(ctx context.Context, repoID int64, filePath string) error
- func (s *Service) ImportFromReader(ctx context.Context, repoID int64, r io.Reader) error
- func (s *Service) Index(ctx context.Context, repoID int64, repoPath string, language string) (*IndexResult, error)
- func (s *Service) IndexWithOptions(ctx context.Context, repoID int64, repoPath string, language string, ...) (*IndexResult, error)
- func (s *Service) IsIndexerAvailable(language string) bool
- func (s *Service) ListFiles(ctx context.Context, repoID int64, limit int) ([]string, error)
- func (s *Service) ListIndexedRepoIDs() ([]int64, error)
- func (s *Service) SearchSymbols(ctx context.Context, repoID int64, query string, limit int) ([]SymbolSearchResult, error)
- func (s *Service) SupportedLanguages() []string
- type Store
- func (s *Store) ClearIndex(ctx context.Context, repoID int64) error
- func (s *Store) Close() error
- func (s *Store) DeleteIndex(ctx context.Context, repoID int64) error
- func (s *Store) EvictCache(repoID int64)
- func (s *Store) FindReferences(ctx context.Context, repoID int64, filePath string, line, col int, limit int) (*ReferencesResult, error)
- func (s *Store) GetDefinition(ctx context.Context, repoID int64, symbol string) (*Occurrence, error)
- func (s *Store) GetIndexMeta(ctx context.Context, repoID int64) (map[string]string, error)
- func (s *Store) GetOccurrenceAtPosition(ctx context.Context, repoID int64, filePath string, line, col int) (*Occurrence, error)
- func (s *Store) GetReferenceCount(ctx context.Context, repoID int64, symbol string) (int, error)
- func (s *Store) GetReferences(ctx context.Context, repoID int64, symbol string, limit int) ([]Occurrence, error)
- func (s *Store) GetSymbolInfo(ctx context.Context, repoID int64, symbol string) (*SymbolInfo, error)
- func (s *Store) GoToDefinition(ctx context.Context, repoID int64, filePath string, line, col int) (*DefinitionResult, error)
- func (s *Store) HasIndex(ctx context.Context, repoID int64) (bool, error)
- func (s *Store) ListFiles(ctx context.Context, repoID int64, limit int) ([]string, error)
- func (s *Store) ListIndexedRepoIDs() ([]int64, error)
- func (s *Store) SearchSymbols(ctx context.Context, repoID int64, query string, limit int) ([]SymbolSearchResult, error)
- func (s *Store) Stats(ctx context.Context, repoID int64) (map[string]any, error)
- type SymbolInfo
- type SymbolSearchResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstallInstructions ¶
InstallInstructions returns instructions for installing SCIP indexers.
func ParseSymbol ¶
ParseSymbol parses a SCIP symbol string into its components. Symbol format: "<scheme> <package> <descriptors>..." or "local <id>".
func SymbolToHumanReadable ¶
SymbolToHumanReadable converts a SCIP symbol to a human-readable name.
Types ¶
type DefinitionResult ¶
type DefinitionResult struct {
Symbol string `json:"symbol"`
Definition *Occurrence `json:"definition,omitempty"`
Info *SymbolInfo `json:"info,omitempty"`
External bool `json:"external"` // True if definition is in external package
}
DefinitionResult contains the result of a go-to-definition query.
type FederatedClient ¶
type FederatedClient struct {
// contains filtered or unexported fields
}
FederatedClient proxies SCIP requests to the correct indexer shard based on repository ownership (FNV-1a hash on repo name).
func NewFederatedClient ¶
func NewFederatedClient(indexerService string, indexerPort, totalShards int) *FederatedClient
NewFederatedClient creates a client for federated SCIP access.
func (*FederatedClient) FindReferences ¶
func (c *FederatedClient) FindReferences( ctx context.Context, repoName string, repoID int64, filePath string, line, column, limit int, ) (json.RawMessage, error)
FindReferences proxies a find-references request to the owning shard. For cross-repo references, this could fan out to all shards in the future.
func (*FederatedClient) GetStats ¶
func (c *FederatedClient) GetStats(ctx context.Context, repoName string, repoID int64) (map[string]any, error)
GetStats proxies a stats request to the owning shard.
func (*FederatedClient) GoToDefinition ¶
func (c *FederatedClient) GoToDefinition( ctx context.Context, repoName string, repoID int64, filePath string, line, column int, ) (json.RawMessage, error)
GoToDefinition proxies a go-to-definition request to the owning shard.
func (*FederatedClient) HasIndex ¶
func (c *FederatedClient) HasIndex(ctx context.Context, repoName string, repoID int64) (bool, error)
HasIndex checks if a SCIP index exists for a repo on its owning shard.
func (*FederatedClient) ListFiles ¶
func (c *FederatedClient) ListFiles( ctx context.Context, repoName string, repoID int64, limit int, ) (json.RawMessage, error)
ListFiles proxies a file listing request to the owning shard.
func (*FederatedClient) SearchSymbols ¶
func (c *FederatedClient) SearchSymbols( ctx context.Context, repoName string, repoID int64, query string, limit int, ) (json.RawMessage, error)
SearchSymbols proxies a symbol search request to the owning shard.
type IndexOptions ¶
type IndexOptions struct {
// CodeHostURL is the URL of the code host (e.g., https://gitlab.example.com)
CodeHostURL string
// CodeHostType is the type of code host (github, gitlab, gitea, bitbucket)
CodeHostType string
// Token is the authentication token for the code host
Token string
// ClearFirst controls whether to clear existing index data before importing.
// When true (default behavior for single-language calls), the index is cleared
// before importing new data. When false, new data is appended to the existing index.
// This is used by the worker for multi-language indexing: clear once before the
// first language, then append for subsequent languages.
ClearFirst bool
}
IndexOptions contains optional parameters for indexing.
type IndexResult ¶
type IndexResult struct {
Success bool `json:"success"`
Language string `json:"language"`
Duration time.Duration `json:"duration"`
Files int `json:"files"`
Symbols int `json:"symbols"`
Occurrences int `json:"occurrences"`
Error string `json:"error,omitempty"`
IndexerOutput string `json:"indexerOutput,omitempty"`
Stats map[string]any `json:"stats,omitempty"`
}
IndexResult contains the result of an indexing operation.
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer runs SCIP indexers for different languages.
func NewIndexer ¶
func NewIndexer(config IndexerConfig, store *Store, logger *zap.Logger) *Indexer
NewIndexer creates a new SCIP indexer.
func (*Indexer) DetectLanguage ¶
DetectLanguage detects the primary language of a repository. It returns the highest-priority language that has at least one project directory.
func (*Indexer) DetectLanguages ¶
DetectLanguages detects all languages present in a repository. It returns languages in priority order (Go, TypeScript, JavaScript, ...).
func (*Indexer) GetAvailableIndexers ¶
GetAvailableIndexers returns which indexers are available on the system.
func (*Indexer) Index ¶
func (i *Indexer) Index( ctx context.Context, repoID int64, repoPath string, language string, ) (*IndexResult, error)
Index runs the appropriate SCIP indexer for a repository.
func (*Indexer) IndexWithOptions ¶
func (i *Indexer) IndexWithOptions( ctx context.Context, repoID int64, repoPath string, language string, opts *IndexOptions, ) (*IndexResult, error)
IndexWithOptions runs the appropriate SCIP indexer for a repository with optional credentials.
func (*Indexer) IsIndexerAvailable ¶
IsIndexerAvailable checks if an indexer is available for a language.
func (*Indexer) SupportedLanguages ¶
SupportedLanguages returns the list of languages with SCIP indexer support.
type IndexerConfig ¶
type IndexerConfig struct {
// Paths to SCIP indexer binaries (optional, will look in PATH if not set)
SCIPTypeScript string `yaml:"scip_typescript"`
SCIPGo string `yaml:"scip_go"`
SCIPJava string `yaml:"scip_java"`
SCIPRust string `yaml:"scip_rust"`
SCIPPython string `yaml:"scip_python"`
// Timeout for indexing operations
Timeout time.Duration `yaml:"timeout"`
// Working directory for temporary files
WorkDir string `yaml:"work_dir"`
}
IndexerConfig holds configuration for SCIP indexers.
func DefaultIndexerConfig ¶
func DefaultIndexerConfig() IndexerConfig
DefaultIndexerConfig returns default configuration.
type Occurrence ¶
type Occurrence struct {
Symbol string `json:"symbol"`
FilePath string `json:"filePath"`
StartLine int `json:"startLine"` // 0-indexed
StartCol int `json:"startCol"` // 0-indexed
EndLine int `json:"endLine"` // 0-indexed
EndCol int `json:"endCol"` // 0-indexed
Role int `json:"role"` // Bitmask: 1=Definition, 2=Import, 4=WriteAccess, 8=ReadAccess
SyntaxKind int `json:"syntaxKind"` // SCIP syntax kind
Context string `json:"context,omitempty"` // The source line content (populated by handlers)
}
Occurrence represents a symbol occurrence in the code.
func (*Occurrence) IsDefinition ¶
func (o *Occurrence) IsDefinition() bool
IsDefinition returns true if this occurrence is a definition.
func (*Occurrence) IsImport ¶
func (o *Occurrence) IsImport() bool
IsImport returns true if this occurrence is an import.
func (*Occurrence) IsReference ¶
func (o *Occurrence) IsReference() bool
IsReference returns true if this occurrence is a read reference.
func (*Occurrence) IsWrite ¶
func (o *Occurrence) IsWrite() bool
IsWrite returns true if this occurrence is a write.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser handles parsing and importing SCIP index files.
func (*Parser) AppendFromBytesWithPrefix ¶
func (p *Parser) AppendFromBytesWithPrefix( ctx context.Context, repoID int64, data []byte, pathPrefix string, ) error
AppendFromBytesWithPrefix imports a SCIP index from raw bytes, prefixing all file paths. Unlike ImportFromBytesWithPrefix, it does NOT clear the existing index first, allowing multiple project indexes to be merged into a single repo index (for monorepos).
func (*Parser) ImportFromBytes ¶
ImportFromBytes imports a SCIP index from raw bytes.
func (*Parser) ImportFromBytesWithPrefix ¶
func (p *Parser) ImportFromBytesWithPrefix( ctx context.Context, repoID int64, data []byte, pathPrefix string, ) error
ImportFromBytesWithPrefix imports a SCIP index from raw bytes, prefixing all file paths. It clears any existing index before importing.
func (*Parser) ImportFromFile ¶
ImportFromFile imports a SCIP index from a file path.
func (*Parser) ImportFromReader ¶
ImportFromReader imports a SCIP index from a reader.
func (*Parser) ImportIndex ¶
ImportIndex imports a parsed SCIP index into the store.
func (*Parser) ImportIndexWithPrefix ¶
func (p *Parser) ImportIndexWithPrefix( ctx context.Context, repoID int64, index *scipproto.Index, pathPrefix string, ) error
ImportIndexWithPrefix imports a parsed SCIP index into the store, prefixing all file paths. It clears any existing index before importing.
type ReferencesResult ¶
type ReferencesResult struct {
Symbol string `json:"symbol"`
Definition *Occurrence `json:"definition,omitempty"`
References []Occurrence `json:"references"`
TotalCount int `json:"totalCount"`
}
ReferencesResult contains the result of a find-references query.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides SCIP-based code intelligence.
func NewService ¶
NewService creates a new SCIP service. cacheDir should be the directory where SCIP databases are stored (e.g., data/scip).
func NewServiceWithConfig ¶
func NewServiceWithConfig(cacheDir string, indexerCfg IndexerConfig, logger *zap.Logger) (*Service, error)
NewServiceWithConfig creates a new SCIP service with an explicit IndexerConfig. This allows callers to configure indexer binary paths and timeouts.
func (*Service) ClearIndex ¶
ClearIndex removes the SCIP index for a repository.
func (*Service) DeleteIndex ¶
DeleteIndex removes the SCIP database files for a repository entirely.
func (*Service) DetectLanguage ¶
DetectLanguage detects the primary language of a repository.
func (*Service) DetectLanguages ¶
DetectLanguages detects all languages present in a repository. Languages are returned in priority order.
func (*Service) EvictCache ¶
EvictCache evicts the in-memory cached connection for a repo.
func (*Service) FindReferences ¶
func (s *Service) FindReferences( ctx context.Context, repoID int64, filePath string, line, col int, limit int, ) (*ReferencesResult, error)
FindReferences finds all references to the symbol at the given position. Line is 1-indexed (from editor), column is 0-indexed. Returns nil if no SCIP index is available or no symbol is at the position.
func (*Service) GetAvailableIndexers ¶
GetAvailableIndexers returns which indexers are available.
func (*Service) GetOccurrenceAtPosition ¶
func (s *Service) GetOccurrenceAtPosition( ctx context.Context, repoID int64, filePath string, line, col int, ) (*Occurrence, error)
GetOccurrenceAtPosition returns the symbol occurrence at a specific position. Line is 1-indexed (from editor), column is 0-indexed.
func (*Service) GetSymbolInfo ¶
func (s *Service) GetSymbolInfo( ctx context.Context, repoID int64, symbol string, ) (*SymbolInfo, error)
GetSymbolInfo returns information about a symbol.
func (*Service) GoToDefinition ¶
func (s *Service) GoToDefinition( ctx context.Context, repoID int64, filePath string, line, col int, ) (*DefinitionResult, error)
GoToDefinition finds the definition of the symbol at the given position. Line is 1-indexed (from editor), column is 0-indexed. Returns nil if no SCIP index is available or no symbol is at the position.
func (*Service) ImportFromBytes ¶
ImportFromBytes imports a SCIP index from raw bytes.
func (*Service) ImportFromFile ¶
ImportFromFile imports a SCIP index from a file.
func (*Service) ImportFromReader ¶
ImportFromReader imports a SCIP index from a reader.
func (*Service) Index ¶
func (s *Service) Index( ctx context.Context, repoID int64, repoPath string, language string, ) (*IndexResult, error)
Index runs the appropriate SCIP indexer for a repository.
func (*Service) IndexWithOptions ¶
func (s *Service) IndexWithOptions( ctx context.Context, repoID int64, repoPath string, language string, opts *IndexOptions, ) (*IndexResult, error)
IndexWithOptions runs the appropriate SCIP indexer with optional credentials.
func (*Service) IsIndexerAvailable ¶
IsIndexerAvailable checks if an indexer is available for a language.
func (*Service) ListIndexedRepoIDs ¶
ListIndexedRepoIDs returns repo IDs that have SCIP database files on disk.
func (*Service) SearchSymbols ¶
func (s *Service) SearchSymbols( ctx context.Context, repoID int64, query string, limit int, ) ([]SymbolSearchResult, error)
SearchSymbols searches for symbols by name pattern.
func (*Service) SupportedLanguages ¶
SupportedLanguages returns the list of supported languages.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides SQLite-based storage for SCIP index data.
func (*Store) ClearIndex ¶
ClearIndex removes all SCIP data for a repository.
func (*Store) DeleteIndex ¶
DeleteIndex removes the SCIP database files for a repository, freeing disk space. Unlike ClearIndex (which empties tables), this removes the SQLite files entirely.
func (*Store) EvictCache ¶
EvictCache closes and removes the in-memory cached connection for a repo. The next access will re-open the database from disk, picking up any changes.
func (*Store) FindReferences ¶
func (s *Store) FindReferences( ctx context.Context, repoID int64, filePath string, line, col int, limit int, ) (*ReferencesResult, error)
FindReferences performs a complete find-references lookup.
func (*Store) GetDefinition ¶
func (s *Store) GetDefinition( ctx context.Context, repoID int64, symbol string, ) (*Occurrence, error)
GetDefinition finds the definition of a symbol. It uses the version-independent symbol path for matching.
func (*Store) GetIndexMeta ¶
GetIndexMeta returns metadata about the SCIP index.
func (*Store) GetOccurrenceAtPosition ¶
func (s *Store) GetOccurrenceAtPosition( ctx context.Context, repoID int64, filePath string, line, col int, ) (*Occurrence, error)
GetOccurrenceAtPosition finds the symbol occurrence at a specific position.
func (*Store) GetReferenceCount ¶
GetReferenceCount returns the count of references to a symbol.
func (*Store) GetReferences ¶
func (s *Store) GetReferences( ctx context.Context, repoID int64, symbol string, limit int, ) ([]Occurrence, error)
GetReferences finds all references to a symbol. It uses the version-independent symbol path for matching to handle cases where the same symbol was indexed at different commits.
func (*Store) GetSymbolInfo ¶
func (s *Store) GetSymbolInfo( ctx context.Context, repoID int64, symbol string, ) (*SymbolInfo, error)
GetSymbolInfo returns information about a symbol.
func (*Store) GoToDefinition ¶
func (s *Store) GoToDefinition( ctx context.Context, repoID int64, filePath string, line, col int, ) (*DefinitionResult, error)
GoToDefinition performs a complete go-to-definition lookup.
func (*Store) ListIndexedRepoIDs ¶
ListIndexedRepoIDs returns the repo IDs that have SCIP database files on disk.
func (*Store) SearchSymbols ¶
func (s *Store) SearchSymbols( ctx context.Context, repoID int64, query string, limit int, ) ([]SymbolSearchResult, error)
SearchSymbols searches for symbols by name pattern.
type SymbolInfo ¶
type SymbolInfo struct {
Symbol string `json:"symbol"`
Documentation string `json:"documentation,omitempty"`
Kind int `json:"kind,omitempty"`
DisplayName string `json:"displayName,omitempty"`
EnclosingSymbol string `json:"enclosingSymbol,omitempty"`
Relationships []string `json:"relationships,omitempty"`
}
SymbolInfo represents metadata about a symbol.
type SymbolSearchResult ¶
type SymbolSearchResult struct {
Symbol string `json:"symbol"`
DisplayName string `json:"displayName,omitempty"`
FilePath string `json:"filePath"`
Line int `json:"line"`
Documentation string `json:"documentation,omitempty"`
}
SymbolSearchResult represents a symbol found by search.