Documentation
¶
Index ¶
- func ChunkText(text string, maxTokens int) []string
- func CreateProjectNode(src *types.Source) types.Node
- func DetectProject(dir string) *types.Source
- func ExtractAll(root string, files []string, provider types.LLMProvider, src *types.Source, ...) ([]types.Node, []types.Edge, error)
- func ExtractAncora(dbPath string, provider types.LLMProvider, maxTokens int, ...) ([]types.Node, []types.Edge, error)
- func ExtractDoc(path string, relFile string, provider types.LLMProvider, maxChunkTokens int) ([]types.Node, []types.Edge, error)
- func ExtractGoEdges(root *sitter.Node, src []byte, relFile string) []types.Edge
- func ExtractGoNodes(root *sitter.Node, src []byte, relFile string) []types.Node
- func ExtractPDF(path string, relFile string, provider types.LLMProvider, maxChunkTokens int) ([]types.Node, []types.Edge, error)
- func ExtractPythonEdges(root *sitter.Node, src []byte, relFile string) []types.Edge
- func ExtractPythonNodes(root *sitter.Node, src []byte, relFile string) []types.Node
- func ExtractTSEdges(root *sitter.Node, src []byte, relFile string) []types.Edge
- func ExtractTSNodes(root *sitter.Node, src []byte, relFile string) []types.Node
- func ParseGoFile(path string) (*sitter.Node, []byte, error)
- func ParsePythonFile(path string) (*sitter.Node, []byte, error)
- func ParseReferences(title, content string) []types.ObsReference
- func ParseTSFile(path string) (*sitter.Node, []byte, error)
- func PrefixedNodeID(project, fileRelPath, symbol string) string
- func ProjectNodeID(name string) string
- func RelPath(root, path string) string
- type LLMExtractor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChunkText ¶
ChunkText splits text into chunks of at most maxTokens (estimated via charsPerToken). Each chunk overlaps with the previous by chunkOverlapRatio of the previous chunk's length to preserve context at boundaries. If the entire text fits within maxTokens, a single-element slice is returned.
func CreateProjectNode ¶
CreateProjectNode creates the root node for a codebase extraction. All file/function nodes link to this via "belongs_to" edges.
func DetectProject ¶
DetectProject extracts project metadata from a directory. Priority:
- Git remote URL → extract repo name (e.g., "github.com/Syfra3/vela" → "vela")
- Fall back to directory basename
Returns a Source with Type=codebase, Name, Path, and Remote (if git).
func ExtractAll ¶
func ExtractAll( root string, files []string, provider types.LLMProvider, src *types.Source, maxChunkTokens ...int, ) ([]types.Node, []types.Edge, error)
ExtractAll dispatches each file to the appropriate extractor and returns the merged set of nodes and edges.
src describes which project this extraction belongs to. If nil, DetectProject is called using root. All returned nodes carry src in Node.Source and have their IDs prefixed with "<project>:". A project root node and one file node per extracted file are also created and linked via "contains" edges.
provider may be nil; if so, doc files are skipped. maxChunkTokens controls chunking for local LLMs (0 = default 8000).
func ExtractAncora ¶
func ExtractAncora( dbPath string, provider types.LLMProvider, maxTokens int, progress func(done, total int, current string), ) ([]types.Node, []types.Edge, error)
ExtractAncora reads all observations from the ancora SQLite database and returns nodes + edges for the knowledge graph.
Graph structure:
Hierarchy nodes: Workspace → Visibility → Organization (when present) Observation nodes: one per observation, linked into the hierarchy Reference edges: explicit references stored in observations.references LLM edges: semantic relations inferred by the LLM provider (optional)
provider may be nil — in that case only structural edges are produced.
func ExtractDoc ¶
func ExtractDoc(path string, relFile string, provider types.LLMProvider, maxChunkTokens int) ([]types.Node, []types.Edge, error)
ExtractDoc reads a markdown or text file, chunks it if necessary, and sends each chunk to the LLM provider for NER + RE extraction.
func ExtractGoEdges ¶
ExtractGoEdges extracts function call edges from the tree-sitter AST. Edges represent caller → callee relationships within the file.
func ExtractGoNodes ¶
ExtractGoNodes extracts named function declarations, struct type declarations, and interface type declarations from the given tree-sitter AST root.
func ExtractPDF ¶
func ExtractPDF(path string, relFile string, provider types.LLMProvider, maxChunkTokens int) ([]types.Node, []types.Edge, error)
ExtractPDF reads a PDF file, converts it to plain text, chunks it, and sends each chunk to the LLM provider for NER + RE extraction.
func ExtractPythonEdges ¶
ExtractPythonEdges extracts call edges from Python function bodies.
func ExtractPythonNodes ¶
ExtractPythonNodes extracts function_definition → function nodes and class_definition → struct nodes from a Python AST.
func ExtractTSEdges ¶
ExtractTSEdges extracts call edges from TypeScript/JavaScript files.
func ExtractTSNodes ¶
ExtractTSNodes extracts functions, arrow functions, classes and interfaces.
func ParseGoFile ¶
ParseGoFile parses a .go source file using tree-sitter and returns the root AST node along with the raw source bytes.
func ParsePythonFile ¶
ParsePythonFile parses a .py source file and returns the root AST node.
func ParseReferences ¶
func ParseReferences(title, content string) []types.ObsReference
ParseReferences extracts explicit references from observation text. It is intentionally conservative — false positives create noise in the graph.
func ParseTSFile ¶
ParseTSFile parses a TypeScript or JavaScript file using tree-sitter. Pass the appropriate language based on the file extension.
func PrefixedNodeID ¶
PrefixedNodeID returns a node ID prefixed with the project name. Format: "<project>:<file>:<symbol>" or "<project>:<file>" for file nodes.
func ProjectNodeID ¶
ProjectNodeID returns the canonical node ID for a project root node. Format: "project:<name>"
Types ¶
type LLMExtractor ¶
type LLMExtractor struct {
// contains filtered or unexported fields
}
LLMExtractor uses an LLM to find implicit references in an observation's content that are not captured by the explicit reference parser. It runs as a worker pool consuming from the Patcher's LLM queue.
func NewLLMExtractor ¶
func NewLLMExtractor(cfg *types.LLMConfig, workerCount int, onRefsFound func(int64, []types.ObsReference)) (*LLMExtractor, error)
NewLLMExtractor creates an extractor using the provided LLM client. workerCount controls how many parallel extraction goroutines are run.
func (*LLMExtractor) Start ¶
func (e *LLMExtractor) Start(ctx context.Context, queue <-chan types.ObservationNode)
Start launches worker goroutines that consume from queue. It returns when ctx is cancelled or queue is closed.