ast

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package ast provides zero-CGO static code analysis and symbol extraction for Go, TypeScript/JavaScript, Python, and SQL files, building deterministic code knowledge graphs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeEntity

type CodeEntity struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Kind      string `json:"kind"` // "func", "struct", "interface", "class", "module", "table"
	File      string `json:"file"`
	Line      int    `json:"line"`
	Package   string `json:"package,omitempty"`
	Signature string `json:"signature,omitempty"`
}

CodeEntity represents a structural symbol discovered in source code.

type CodeRelationship

type CodeRelationship struct {
	Source     string  `json:"source"`
	Target     string  `json:"target"`
	Relation   string  `json:"relation"` // "calls", "imports", "implements", "defines", "uses"
	Confidence float64 `json:"confidence"`
	Reasoning  string  `json:"reasoning,omitempty"`
}

CodeRelationship represents a directed edge between two code entities.

type ExtractionResult

type ExtractionResult struct {
	Entities      []CodeEntity       `json:"entities"`
	Relationships []CodeRelationship `json:"relationships"`
	FilesScanned  int                `json:"files_scanned"`
}

ExtractionResult is the output of analyzing a file or directory tree.

type Extractor

type Extractor struct {
	RootPath string
}

Extractor performs static AST and regex-based symbol analysis.

func NewExtractor

func NewExtractor(root string) *Extractor

NewExtractor creates a new AST extractor rooted at the given path.

func (*Extractor) ExtractDir

func (e *Extractor) ExtractDir(dir string, maxFiles int) (*ExtractionResult, error)

ExtractDir scans a directory recursively and extracts code entities and relationships.

func (*Extractor) ExtractFile

func (e *Extractor) ExtractFile(filePath string) (*ExtractionResult, error)

ExtractFile extracts code entities and relationships for a single file.

func (*Extractor) ExtractPath

func (e *Extractor) ExtractPath(targetPath string, maxFiles int) (*ExtractionResult, error)

ExtractPath scans either a single file or a directory recursively.

Jump to

Keyboard shortcuts

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