server

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSocketPath

func GetSocketPath() string

GetSocketPath returns the default path to the Unix socket (for backwards compatibility)

func GetSocketPathForRoot added in v0.4.0

func GetSocketPathForRoot(root string) string

GetSocketPathForRoot returns a project-specific socket path based on the root directory This allows multiple servers to run for different projects simultaneously

Types

type Client

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

Client connects to a remote IndexServer

func NewClient

func NewClient() *Client

NewClient creates a new client connection to the index server using the default socket path

func NewClientWithSocket added in v0.4.0

func NewClientWithSocket(socketPath string) *Client

NewClientWithSocket creates a new client connection to the index server with a custom socket path

func (*Client) GetDefinition added in v0.4.0

func (c *Client) GetDefinition(pattern string, maxResults int) ([]DefinitionLocation, error)

GetDefinition searches for symbol definitions by name pattern

func (*Client) GetFileInfo

func (c *Client) GetFileInfo(fileID types.FileID) (*types.FileInfo, error)

GetFileInfo retrieves file information

func (*Client) GetReferences added in v0.4.0

func (c *Client) GetReferences(pattern string, maxResults int) ([]ReferenceLocation, error)

GetReferences searches for symbol references (usages) by name pattern

func (*Client) GetStats added in v0.4.0

func (c *Client) GetStats() (*StatsResponse, error)

GetStats retrieves index statistics from the server

func (*Client) GetStatus

func (c *Client) GetStatus() (*IndexStatus, error)

GetStatus retrieves the current index status

func (*Client) GetSymbol

func (c *Client) GetSymbol(symbolID types.SymbolID) (*types.EnhancedSymbol, error)

GetSymbol retrieves symbol information

func (*Client) GetTree added in v0.4.0

func (c *Client) GetTree(functionName string, maxDepth int, showLines, compact, agentMode bool, exclude string) (*types.FunctionTree, error)

GetTree generates a function call hierarchy tree

func (*Client) GitAnalyze added in v0.4.0

func (c *Client) GitAnalyze(req GitAnalyzeRequest) (interface{}, error)

GitAnalyze performs git change analysis

func (*Client) IsServerRunning

func (c *Client) IsServerRunning() bool

IsServerRunning checks if the server is accessible

func (*Client) Ping

func (c *Client) Ping() (*PingResponse, error)

Ping sends a health check to the server

func (*Client) Reindex

func (c *Client) Reindex(path string) error

Reindex triggers a re-index of the project

func (*Client) Search

func (c *Client) Search(pattern string, options types.SearchOptions, maxResults int) ([]searchtypes.Result, error)

Search performs a search query on the remote index

func (*Client) Shutdown

func (c *Client) Shutdown(force bool) error

Shutdown requests the server to shut down

func (*Client) WaitForReady

func (c *Client) WaitForReady(timeout time.Duration) error

WaitForReady waits until the index is ready or timeout

type DefinitionLocation added in v0.4.0

type DefinitionLocation struct {
	Name       string `json:"name"`                  // Symbol name
	Type       string `json:"type"`                  // Symbol type (function, class, struct, interface, type, method)
	FilePath   string `json:"file_path"`             // Full file path
	Line       int    `json:"line"`                  // Line number (1-based)
	Column     int    `json:"column"`                // Column number (0-based)
	Signature  string `json:"signature,omitempty"`   // Function/method signature if available
	DocComment string `json:"doc_comment,omitempty"` // Documentation comment if available
}

DefinitionLocation represents a single definition location

type DefinitionRequest added in v0.4.0

type DefinitionRequest struct {
	Pattern    string `json:"pattern"`               // Symbol name pattern to search for
	MaxResults int    `json:"max_results,omitempty"` // Maximum number of results to return
}

DefinitionRequest requests symbol definition locations

type DefinitionResponse added in v0.4.0

type DefinitionResponse struct {
	Definitions []DefinitionLocation `json:"definitions"`
	Error       string               `json:"error,omitempty"`
}

DefinitionResponse contains definition search results

type GetFileInfoRequest

type GetFileInfoRequest struct {
	FileID types.FileID `json:"file_id"`
}

GetFileInfoRequest requests file information

type GetFileInfoResponse

type GetFileInfoResponse struct {
	FileInfo *types.FileInfo `json:"file_info,omitempty"`
	Error    string          `json:"error,omitempty"`
}

GetFileInfoResponse contains file information

type GetSymbolRequest

type GetSymbolRequest struct {
	SymbolID types.SymbolID `json:"symbol_id"`
}

GetSymbolRequest requests symbol information

type GetSymbolResponse

type GetSymbolResponse struct {
	Symbol *types.EnhancedSymbol `json:"symbol,omitempty"`
	Error  string                `json:"error,omitempty"`
}

GetSymbolResponse contains symbol information

type GitAnalyzeRequest added in v0.4.0

type GitAnalyzeRequest struct {
	Scope               string   `json:"scope"` // staged, wip, commit, range
	BaseRef             string   `json:"base_ref,omitempty"`
	TargetRef           string   `json:"target_ref,omitempty"`
	Focus               []string `json:"focus,omitempty"` // duplicates, naming, metrics
	SimilarityThreshold float64  `json:"similarity_threshold,omitempty"`
	MaxFindings         int      `json:"max_findings,omitempty"`
}

GitAnalyzeRequest requests git change analysis

type GitAnalyzeResponse added in v0.4.0

type GitAnalyzeResponse struct {
	Report interface{} `json:"report,omitempty"` // *git.AnalysisReport
	Error  string      `json:"error,omitempty"`
}

GitAnalyzeResponse contains the git analysis report

type IndexServer

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

IndexServer manages a persistent index that can be shared between CLI and MCP

func NewIndexServer

func NewIndexServer(cfg *config.Config) (*IndexServer, error)

NewIndexServer creates a new persistent index server

func NewIndexServerWithIndex

func NewIndexServerWithIndex(cfg *config.Config, indexer *indexing.MasterIndex, searchEngine *search.Engine) (*IndexServer, error)

NewIndexServerWithIndex creates a new persistent index server with an existing MasterIndex This is used when the index is managed externally (e.g., by MCP)

func (*IndexServer) GetMemoryStats

func (s *IndexServer) GetMemoryStats() runtime.MemStats

GetMemoryStats returns current memory usage

func (*IndexServer) GetServerSocketPath added in v0.4.0

func (s *IndexServer) GetServerSocketPath() string

GetServerSocketPath returns the socket path this server is using

func (*IndexServer) SetSocketPath added in v0.4.0

func (s *IndexServer) SetSocketPath(path string)

SetSocketPath sets a custom socket path for this server (used for testing)

func (*IndexServer) Shutdown

func (s *IndexServer) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server

func (*IndexServer) Start

func (s *IndexServer) Start() error

Start begins listening for client connections

func (*IndexServer) Wait

func (s *IndexServer) Wait()

Wait blocks until the server is shut down

type IndexStatus

type IndexStatus struct {
	Ready          bool    `json:"ready"`
	FileCount      int     `json:"file_count"`
	SymbolCount    int     `json:"symbol_count"`
	IndexingActive bool    `json:"indexing_active"`
	Progress       float64 `json:"progress"`
	Error          string  `json:"error,omitempty"`
}

IndexStatus represents the current status of the index

type PingRequest

type PingRequest struct{}

PingRequest for health check

type PingResponse

type PingResponse struct {
	Uptime  float64 `json:"uptime_seconds"`
	Version string  `json:"version"`
}

PingResponse confirms server is alive

type ReferenceLocation added in v0.4.0

type ReferenceLocation struct {
	FilePath string `json:"file_path"` // Full file path
	Line     int    `json:"line"`      // Line number (1-based)
	Column   int    `json:"column"`    // Column number (0-based)
	Context  string `json:"context"`   // Line content or surrounding context
	Match    string `json:"match"`     // The matched text
}

ReferenceLocation represents a single reference location

type ReferencesRequest added in v0.4.0

type ReferencesRequest struct {
	Pattern    string `json:"pattern"`               // Symbol name pattern to search for
	MaxResults int    `json:"max_results,omitempty"` // Maximum number of results to return
}

ReferencesRequest requests symbol reference locations (usages)

type ReferencesResponse added in v0.4.0

type ReferencesResponse struct {
	References []ReferenceLocation `json:"references"`
	Error      string              `json:"error,omitempty"`
}

ReferencesResponse contains reference search results

type ReindexRequest

type ReindexRequest struct {
	Path string `json:"path,omitempty"` // Empty means use configured root
}

ReindexRequest triggers a re-index

type ReindexResponse

type ReindexResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message,omitempty"`
}

ReindexResponse confirms re-indexing started

type SearchRequest

type SearchRequest struct {
	Pattern    string              `json:"pattern"`
	Options    types.SearchOptions `json:"options"`
	MaxResults int                 `json:"max_results,omitempty"`
}

SearchRequest represents a search request from a client

type SearchResponse

type SearchResponse struct {
	Results []searchtypes.Result `json:"results"`
	Error   string               `json:"error,omitempty"`
}

SearchResponse contains search results

type ShutdownRequest

type ShutdownRequest struct {
	Force bool `json:"force,omitempty"`
}

ShutdownRequest requests server shutdown

type ShutdownResponse

type ShutdownResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message,omitempty"`
}

ShutdownResponse confirms shutdown

type StatsRequest added in v0.4.0

type StatsRequest struct{}

StatsRequest requests index statistics

type StatsResponse added in v0.4.0

type StatsResponse struct {
	FileCount       int     `json:"file_count"`
	SymbolCount     int     `json:"symbol_count"`
	IndexSizeBytes  int64   `json:"index_size_bytes"`
	BuildDurationMs int64   `json:"build_duration_ms"`
	MemoryAllocMB   float64 `json:"memory_alloc_mb"`
	MemoryTotalMB   float64 `json:"memory_total_mb"`
	MemoryHeapMB    float64 `json:"memory_heap_mb"`
	NumGoroutines   int     `json:"num_goroutines"`
	UptimeSeconds   float64 `json:"uptime_seconds"`
	SearchCount     int64   `json:"search_count,omitempty"`
	AvgSearchTimeMs float64 `json:"avg_search_time_ms,omitempty"`
	Error           string  `json:"error,omitempty"`
}

StatsResponse contains index statistics

type TreeRequest added in v0.4.0

type TreeRequest struct {
	FunctionName string `json:"function_name"`        // Function name to generate tree for
	MaxDepth     int    `json:"max_depth,omitempty"`  // Maximum depth to traverse (0 = unlimited)
	ShowLines    bool   `json:"show_lines,omitempty"` // Include line numbers
	Compact      bool   `json:"compact,omitempty"`    // Use compact output format
	Exclude      string `json:"exclude,omitempty"`    // Pattern to exclude from tree
	AgentMode    bool   `json:"agent_mode,omitempty"` // Enable agent-friendly output with safety info
}

TreeRequest requests a function call tree

type TreeResponse added in v0.4.0

type TreeResponse struct {
	Tree  *types.FunctionTree `json:"tree,omitempty"`
	Error string              `json:"error,omitempty"`
}

TreeResponse contains the function call tree

Jump to

Keyboard shortcuts

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