model

package
v0.0.0-...-6320ad3 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FunctionDefinitionToKey

func FunctionDefinitionToKey(def FunctionDefinition) string

Types

type CallEdge

type CallEdge struct {
	From *FunctionDefinition `json:"from"`
	To   *FunctionDefinition `json:"to"`
}

func (CallEdge) ToKey

func (e CallEdge) ToKey() string

type CallGraph

type CallGraph struct {
	Roots     []FunctionDefinition `json:"roots"`
	Functions []FunctionDefinition `json:"functions"`
	Edges     []CallEdge           `json:"edges"`
	// contains filtered or unexported fields
}

func NewCallGraph

func NewCallGraph() *CallGraph

func (*CallGraph) AddFunctionDependency

func (cg *CallGraph) AddFunctionDependency(caller *FunctionDefinition, dep *FunctionDependency)

type ChunkType

type ChunkType string

ChunkType represents the hierarchical level of a code chunk

const (
	ChunkTypeFile            ChunkType = "file"
	ChunkTypeClass           ChunkType = "class"
	ChunkTypeFunction        ChunkType = "function"
	ChunkTypeBlock           ChunkType = "block"
	ChunkTypeConditional     ChunkType = "conditional"      // if, else, switch, case
	ChunkTypeLoop            ChunkType = "loop"             // for, while, do-while
	ChunkTypeMethodSignature ChunkType = "method_signature" // For semantic signature search
)

type CodeChunk

type CodeChunk struct {
	// Unique identifier for this chunk
	ID string `json:"id"`

	// FileID from MySQL file_versions table (shared with CodeGraph)
	FileID int32 `json:"file_id"`

	// Hierarchical metadata
	ChunkType ChunkType `json:"chunk_type"`
	Level     int       `json:"level"` // 1=file, 2=class, 3=function, 4=block
	ParentID  string    `json:"parent_id,omitempty"`

	// Code content
	Content   string     `json:"content"`
	Language  string     `json:"language"`
	FilePath  string     `json:"file_path"`
	StartLine int        `json:"start_line"`
	EndLine   int        `json:"end_line"`
	Range     base.Range `json:"range"`

	// Semantic metadata
	Name      string `json:"name,omitempty"`      // Function/class/file name
	Signature string `json:"signature,omitempty"` // Function signature
	Docstring string `json:"docstring,omitempty"` // Documentation

	// Context for better understanding
	ModuleName string `json:"module_name,omitempty"` // Package/module name
	ClassName  string `json:"class_name,omitempty"`  // Parent class if method

	// Vector embedding (generated by embedding model)
	Embedding []float32 `json:"embedding,omitempty"`

	// Additional metadata
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

CodeChunk represents a hierarchical piece of code with vector embedding

func NewCodeChunk

func NewCodeChunk(id string, chunkType ChunkType, level int, content, language, filePath string, rng base.Range) *CodeChunk

NewCodeChunk creates a new code chunk with basic information

func (*CodeChunk) GetSearchableText

func (c *CodeChunk) GetSearchableText(includeContext bool) string

GetSearchableText returns the text representation for embedding generation Truncates content to avoid exceeding embedding model context limits includeContext: if true, includes module/class context; if false, only includes the code content

func (*CodeChunk) WithContext

func (c *CodeChunk) WithContext(moduleName, className string) *CodeChunk

WithContext sets the module and class context

func (*CodeChunk) WithDocstring

func (c *CodeChunk) WithDocstring(docstring string) *CodeChunk

WithDocstring sets the documentation string

func (*CodeChunk) WithEmbedding

func (c *CodeChunk) WithEmbedding(embedding []float32) *CodeChunk

WithEmbedding sets the vector embedding

func (*CodeChunk) WithFileID

func (c *CodeChunk) WithFileID(fileID int32) *CodeChunk

WithFileID sets the FileID from MySQL

func (*CodeChunk) WithMetadata

func (c *CodeChunk) WithMetadata(key string, value interface{}) *CodeChunk

WithMetadata adds custom metadata

func (*CodeChunk) WithName

func (c *CodeChunk) WithName(name string) *CodeChunk

WithName sets the name (function/class/module name)

func (*CodeChunk) WithParent

func (c *CodeChunk) WithParent(parentID string) *CodeChunk

WithParent sets the parent chunk ID

func (*CodeChunk) WithSignature

func (c *CodeChunk) WithSignature(signature string) *CodeChunk

WithSignature sets the function signature

type FileInfo

type FileInfo struct {
	Path     string `json:"path"`
	Language string `json:"language"`
}

type FunctionDefinition

type FunctionDefinition struct {
	Name       string        `json:"name"`
	Location   base.Location `json:"location"`
	IsExternal bool          `json:"is_external"`
	Module     string        `json:"module,omitempty"`
	Params     string        `json:"params"`
	Returns    string        `json:"returns"`
}

func MapToFunctionFromDocumentSymbol

func MapToFunctionFromDocumentSymbol(uri string, sym *base.DocumentSymbol) FunctionDefinition

func MapToFunctionFromSymbolInformation

func MapToFunctionFromSymbolInformation(uri string, sym *base.SymbolInformation) FunctionDefinition

func (*FunctionDefinition) ToKey

func (fn *FunctionDefinition) ToKey() string

type FunctionDependency

type FunctionDependency struct {
	Name          string             `json:"name"`
	CallLocations []base.Location    `json:"call_locations"`
	Definition    FunctionDefinition `json:"definition"`
}

func MapToFunctionDependency

func MapToFunctionDependency(call base.CallHierarchyOutgoingCall, lspClient base.LSPClient) FunctionDependency

func (*FunctionDependency) IsIn

func (fd *FunctionDependency) IsIn(rng *base.Range) bool

type FunctionDetails

type FunctionDetails struct {
	Name          string        `json:"name"`
	Signature     string        `json:"signature"`
	Parameters    []Parameter   `json:"parameters"`
	ReturnType    string        `json:"return_type"`
	IsAsync       bool          `json:"is_async"`
	Documentation string        `json:"documentation"`
	Location      base.Location `json:"location"`
}

type GetFunctionDependenciesRequest

type GetFunctionDependenciesRequest struct {
	RepoName     string `json:"repo_name" binding:"required"`
	RelativePath string `json:"relative_path" binding:"required"`
	FunctionName string `json:"function_name" binding:"required"`
	Depth        int    `json:"depth"`
}

type GetFunctionDependenciesResponse

type GetFunctionDependenciesResponse struct {
	RepoName     string               `json:"repo_name"`
	FilePath     string               `json:"file_path"`
	FunctionName string               `json:"function_name"`
	Dependencies []FunctionDependency `json:"dependencies"`
}

type GetFunctionDetailsRequest

type GetFunctionDetailsRequest struct {
	RepoName     string `json:"repo_name" binding:"required"`
	RelativePath string `json:"relative_path" binding:"required"`
	FunctionName string `json:"function_name" binding:"required"`
}

type GetFunctionDetailsResponse

type GetFunctionDetailsResponse struct {
	RepoName     string          `json:"repo_name"`
	FilePath     string          `json:"file_path"`
	FunctionName string          `json:"function_name"`
	Details      FunctionDetails `json:"details"`
}

type GetFunctionsInFileRequest

type GetFunctionsInFileRequest struct {
	RepoName     string `json:"repo_name" binding:"required"`
	RelativePath string `json:"relative_path" binding:"required"`
}

type GetFunctionsInFileResponse

type GetFunctionsInFileResponse struct {
	RepoName  string               `json:"repo_name"`
	FilePath  string               `json:"file_path"`
	Functions []FunctionDefinition `json:"functions"`
}

type Parameter

type Parameter struct {
	Name          string `json:"name"`
	Type          string `json:"type"`
	Optional      bool   `json:"optional"`
	Documentation string `json:"documentation"`
}

type ProcessDirectoryRequest

type ProcessDirectoryRequest struct {
	RepoName       string `json:"repo_name" binding:"required"`
	CollectionName string `json:"collection_name"`
}

type ProcessDirectoryResponse

type ProcessDirectoryResponse struct {
	RepoName       string `json:"repo_name"`
	CollectionName string `json:"collection_name"`
	TotalChunks    int    `json:"total_chunks"`
	Success        bool   `json:"success"`
	Message        string `json:"message,omitempty"`
}

type ProcessRepoResponse

type ProcessRepoResponse struct {
	RepoName  string               `json:"repo_name"`
	Files     []FileInfo           `json:"files"`
	Functions []FunctionDefinition `json:"functions"`
}

type QueryInfo

type QueryInfo struct {
	CodeSnippet string       `json:"code_snippet"`
	Language    string       `json:"language"`
	ChunksFound int          `json:"chunks_found"`
	Chunks      []*CodeChunk `json:"chunks"` // The parsed chunks from the input snippet
}

type SearchSimilarCodeRequest

type SearchSimilarCodeRequest struct {
	RepoName       string `json:"repo_name" binding:"required"`
	CollectionName string `json:"collection_name"`
	CodeSnippet    string `json:"code_snippet" binding:"required"`
	Language       string `json:"language" binding:"required"`
	Limit          int    `json:"limit"`
	IncludeCode    bool   `json:"include_code"`
}

type SearchSimilarCodeResponse

type SearchSimilarCodeResponse struct {
	RepoName       string              `json:"repo_name"`
	CollectionName string              `json:"collection_name"`
	Query          QueryInfo           `json:"query"`
	Results        []SimilarCodeResult `json:"results"`
	Success        bool                `json:"success"`
	Message        string              `json:"message,omitempty"`
}

type SimilarCodeResult

type SimilarCodeResult struct {
	Chunk           *CodeChunk `json:"chunk"`
	Score           float32    `json:"score"`
	QueryChunkIndex int        `json:"query_chunk_index"` // Index of the input chunk that matched this result (0-based)
	Code            string     `json:"code,omitempty"`    // Actual code content from file (if include_code is true)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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