Documentation
¶
Index ¶
- Constants
- func CreateProjectNode(src *types.Source) types.Node
- func DetectProject(dir string) *types.Source
- func DetectProjectInWorkspace(workspaceRoot, dir string) *types.Source
- func DiscoverChildGitRepos(root string) ([]string, error)
- func ExtractAll(root string, files []string, _ types.LLMProvider, src *types.Source, _ ...int) ([]types.Node, []types.Edge, error)
- func ExtractContract(root string, files []string, src *types.Source) ([]types.Node, []types.Edge, error)
- func ExtractGoEdges(parsed *parsedGoFile, _ []byte, relFile string) []types.Edge
- func ExtractGoNodes(parsed *parsedGoFile, _ []byte, relFile string) []types.Node
- 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 IsContractFile(path string) bool
- func IsGitRepoRoot(dir string) bool
- func ParseGoFile(path string) (*parsedGoFile, []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
- func SourceDisplayName(src *types.Source) string
- func SourceIdentity(src *types.Source) string
Constants ¶
const ( EvidenceTypeOpenAPI = "openapi" EvidenceTypeProto = "proto" )
Evidence type tags specific to the contract layer.
const ( MetaLayer = "layer" MetaEvidenceType = "evidence_type" MetaEvidenceConfidence = "evidence_confidence" MetaEvidenceSourceArtifact = "evidence_source_artifact" )
Metadata keys stamped onto extracted nodes and edges so that downstream layers (graph insertion, chunking, retrieval, evidence attribution) have a uniform, layer-aware contract independent of which extractor produced them.
Canonical identity is still assigned by ExtractAll (project prefixing, file node IDs); extractors only produce layer-local metadata here — they must not invent graph-level identity.
const ( EvidenceTypeAST = "ast" EvidenceTypeDocLLM = "doc-llm" EvidenceTypePDFLLM = "pdf-llm" EvidenceTypeFilesystem = "filesystem" EvidenceTypeProject = "project" )
Evidence type tags used when stamping extraction output. These correspond to the Evidence.Type field in pkg/types and let the orchestrator attribute retrieval hits back to the extractor that produced them.
Variables ¶
This section is empty.
Functions ¶
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 DetectProjectInWorkspace ¶ added in v1.7.1
DetectProjectInWorkspace derives a stable repo identity for dir relative to a selected workspace root when a git remote is unavailable.
func DiscoverChildGitRepos ¶ added in v1.7.1
DiscoverChildGitRepos finds nested git repositories below root.
func ExtractAll ¶
func ExtractAll( root string, files []string, _ types.LLMProvider, src *types.Source, _ ...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 ExtractContract ¶ added in v1.4.0
func ExtractContract(root string, files []string, src *types.Source) ([]types.Node, []types.Edge, error)
ExtractContract parses the supplied set of files, keeping only those recognised as contract artifacts, and returns contract-layer nodes + edges stamped with declared evidence.
src is the repo/workspace context the artifacts were discovered in — the extractor emits a workspace-consumable binding edge (`declared_in`) from each service to the project node so workspace routing can pick up declared services without re-reading the artifact. If src is nil no binding edges are emitted (the contract graph is still produced).
func ExtractGoEdges ¶
ExtractGoEdges extracts function call edges from a parsed Go AST.
func ExtractGoNodes ¶
ExtractGoNodes extracts named function declarations, struct type declarations, and interface type declarations from a parsed Go file.
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 IsContractFile ¶ added in v1.4.0
IsContractFile returns true when a path looks like a declared contract artifact supported by this extractor.
func IsGitRepoRoot ¶ added in v1.7.1
IsGitRepoRoot reports whether dir itself is a git repository root.
func ParseGoFile ¶
ParseGoFile parses a .go source file using go/ast (pure Go, no CGO).
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>"
func SourceDisplayName ¶ added in v1.7.1
func SourceIdentity ¶ added in v1.7.1
Types ¶
This section is empty.