Documentation
¶
Overview ¶
Package parser — heuristic.go: post-AST pass that injects synthetic HANDLES edges for framework routing registrations (R1).
Detects patterns such as:
- Go: http.HandleFunc("/path", handler), r.GET("/path", handler)
- TS: app.get('/path', handler), router.post('/path', handler)
- Py: @app.get('/path'), path('/path', view)
For each match, a virtual NodeRoute node is created representing the route, and two synthetic edges are injected:
enclosingFn --CALLS--> routeNode routeNode --HANDLES--> handlerFn
Both edges are synthetic (not derived from AST call resolution) and are skipped if either endpoint cannot be resolved in the current graph. Confidence is stored in routeNode.Metadata["confidence"] (0.0–1.0 as string).
Package parser — nl_extract.go implements Tier 0 NL-to-graph entity extraction.
Tier 0 is always-on: pure Go, zero dependencies, zero cost. Given markdown body text it returns named entity candidates and relationship signals without any LLM or embedding call. Quality alone is ~50% of full NL extraction — already better than no extraction at all.
Pipeline position:
Tier 0 (this file) → Tier 1 (resolver/nl_entities.go, name-match resolution)
→ Tier 2 (brain/client.go, P1 LLM classification)
Package parser converts source files into graph nodes and edges using Tree-sitter for accurate, incremental, multi-language AST parsing.
Index ¶
- Constants
- func ApplyHeuristics(g *graph.Graph, filePath string, src []byte)
- func ApplyProvenance(g *graph.Graph, path string, src []byte)
- func DetectProvenance(path string, src []byte) graph.ProvenanceType
- func InjectHandlesEdges(g *graph.Graph, registrations []RouteRegistration) int
- func ResolveProtoTypeRefs(g *graph.Graph) int
- type BashParser
- type BicepParser
- type CMakeParser
- type CParser
- type CSSParser
- type CSharpParser
- type CUEParser
- type ClojureParser
- type CppParser
- type DartParser
- type DockerfileParser
- func (p *DockerfileParser) Extensions() []string
- func (p *DockerfileParser) FilenamePrefixes() []string
- func (p *DockerfileParser) Filenames() []string
- func (p *DockerfileParser) Parse(g *graph.Graph, filePath string, src []byte) error
- func (p *DockerfileParser) TSLanguageForFile(_ string) *sitter.Language
- type ElixirParser
- type ElmParser
- type EntityCandidate
- type ErlangParser
- type FSharpParser
- type FilenameParser
- type FilenamePatternParser
- type GoParser
- type GraphQLParser
- type GroovyParser
- type HCLParser
- type HaskellParser
- type JSONParser
- type JavaParser
- type JavaScriptParser
- type JsonnetParser
- type JuliaParser
- type KotlinParser
- type LanguageParser
- type LogicWarning
- type LuaParser
- type MATLABParser
- type MakefileParser
- type MarkdownParser
- type NixParser
- type OCamlParser
- type ObjCParser
- type PHPParser
- type PerlParser
- type PlaintextParser
- type PluginChecker
- type PluginParser
- type PowerShellParser
- type ProtobufParser
- type PythonParser
- type RBSParser
- type RParser
- type RelationshipSignal
- type RouteRegistration
- type RubyParser
- type RustParser
- type SCSSParser
- type SQLParser
- type ScalaParser
- type SolidityParser
- type StarlarkParser
- type SvelteParser
- type SwiftParser
- type TOMLParser
- type TerraformParser
- type ThriftParser
- type TreeSitterLanguageProvider
- type TypeScriptParser
- type VueParser
- type Walker
- func (w *Walker) HasParseErrors(path string, src []byte) bool
- func (w *Walker) IncrementalReindex(g *graph.Graph, root string, known map[string]int64) (fresh map[string]int64, changed, removed int, err error)
- func (w *Walker) ParseFile(g *graph.Graph, path string) error
- func (w *Walker) ParseFileSrc(g *graph.Graph, path string, src []byte) error
- func (w *Walker) Register(p LanguageParser)
- func (w *Walker) RegisterPlugin(extensions []string, command string, checker *PluginChecker)
- func (w *Walker) WalkDir(g *graph.Graph, root string) (map[string]int64, error)
- type XMLParser
- type YAMLParser
- type ZigParser
Constants ¶
const DefaultParseTimeout = 30 * time.Second
DefaultParseTimeout is the maximum time allowed for tree-sitter to parse a single file.
Variables ¶
This section is empty.
Functions ¶
func ApplyHeuristics ¶
ApplyHeuristics is the convenience entry-point called from WalkDir / ParseFile. It extracts route registrations from src and injects HANDLES edges into g.
func ApplyProvenance ¶
ApplyProvenance sets the Provenance field on all nodes belonging to path. Called by WalkDir/IncrementalReindex/ParseFile immediately after a successful parse so that every node carries its trust tier from the moment it enters the graph. Nodes in user-authored files are left unchanged (ProvenanceUserAuthored is the zero value).
func DetectProvenance ¶
func DetectProvenance(path string, src []byte) graph.ProvenanceType
DetectProvenance derives the provenance tier for a file from its path and the first 512 bytes of content. Runs at index time with no LLM or I/O beyond what the parser has already read.
Priority order:
- Vendored — path contains vendor/, node_modules/, third_party/
- Generated — file name matches codegen suffixes, OR file starts with a well-known codegen header comment
- UserAuthored — everything else (the safe default)
func InjectHandlesEdges ¶
func InjectHandlesEdges(g *graph.Graph, registrations []RouteRegistration) int
InjectHandlesEdges resolves registrations to graph nodes and creates synthetic route nodes + HANDLES edges. Returns the number of edges injected.
func ResolveProtoTypeRefs ¶
ResolveProtoTypeRefs creates DEPENDS_ON edges from fields to their message/enum types within the same proto graph. This enables impact analysis: changing a message type surfaces all messages that reference it. Must be called after all proto files in the project are parsed.
Types ¶
type BashParser ¶
type BashParser struct {
// contains filtered or unexported fields
}
BashParser parses Bash/Shell (.sh, .bash) source files.
func NewBashParser ¶
func NewBashParser() *BashParser
NewBashParser creates a ready-to-use BashParser.
func (*BashParser) Extensions ¶
func (p *BashParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*BashParser) TSLanguageForFile ¶
func (p *BashParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type BicepParser ¶
type BicepParser struct {
// contains filtered or unexported fields
}
BicepParser parses Azure Bicep (.bicep) infrastructure-as-code files. It extracts:
- Parameters (param name type = default) → NodeVariable (kind=parameter)
- Variables (var name = value) → NodeVariable (kind=variable)
- Resources (resource symbolicName 'Type@api' = {...}) → NodeStruct (kind=resource)
- Modules (module symbolicName 'path' = {...}) → NodeStruct (kind=module)
- Outputs (output name type = value) → NodeVariable (kind=output)
Decorators (@description, @allowed) preceding declarations are collected and stored in metadata.
func NewBicepParser ¶
func NewBicepParser() *BicepParser
NewBicepParser creates a ready-to-use BicepParser.
func (*BicepParser) Extensions ¶
func (p *BicepParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*BicepParser) Parse ¶
Parse extracts code entities from a single Bicep file.
The Bicep grammar root node is "infrastructure". Its direct children are:
- decorators: one or more @decorator nodes preceding a declaration
- parameter_declaration, variable_declaration, resource_declaration, module_declaration, output_declaration
Decorators are collected as they appear and applied to the immediately following declaration node.
func (*BicepParser) TSLanguageForFile ¶
func (p *BicepParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for the given file.
type CMakeParser ¶
type CMakeParser struct {
// contains filtered or unexported fields
}
CMakeParser parses CMake (.cmake, CMakeLists.txt) source files. It extracts functions, macros, targets (add_executable/add_library), variables (set/option), and includes (include/find_package).
func NewCMakeParser ¶
func NewCMakeParser() *CMakeParser
NewCMakeParser creates a ready-to-use CMakeParser.
func (*CMakeParser) Extensions ¶
func (p *CMakeParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*CMakeParser) Filenames ¶
func (p *CMakeParser) Filenames() []string
Filenames returns the exact base filenames handled by this parser.
func (*CMakeParser) Parse ¶
Parse extracts code entities from a single CMake file and merges them into the graph.
Extracts:
- File node (NodeFile)
- function() definitions -> NodeFunction
- macro() definitions -> NodeFunction with kind="macro"
- add_executable/add_library targets -> NodeStruct with kind="target"
- set/option variables -> NodeVariable
- include/find_package -> EdgeImports
func (*CMakeParser) TSLanguageForFile ¶
func (p *CMakeParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type CParser ¶
type CParser struct {
// contains filtered or unexported fields
}
CParser parses C (.c, .h) source files.
func (*CParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
type CSSParser ¶
type CSSParser struct {
// contains filtered or unexported fields
}
CSSParser parses CSS (.css) source files using tree-sitter.
func (*CSSParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
func (*CSSParser) Parse ¶
Parse extracts code entities from a single CSS file and merges them into the graph.
Extracts:
- @import rules → EdgeImports to NodePackage nodes
- Rule-set selectors (.class, #id) → NodeStruct with kind="selector"
- @keyframes definitions → NodeFunction with kind="keyframes"
- CSS custom property definitions (--var) → NodeVariable with kind="custom-property"
- @font-face font-family names → NodeVariable with kind="font-face"
- animation / animation-name references → EdgeCalls to keyframes nodes
- var(--name) references → EdgeCalls to custom-property nodes
- Selectors inside @media, @supports, @layer are fully handled (recursive walk)
type CSharpParser ¶
type CSharpParser struct {
// contains filtered or unexported fields
}
CSharpParser parses C# (.cs) source files.
func NewCSharpParser ¶
func NewCSharpParser() *CSharpParser
NewCSharpParser creates a ready-to-use CSharpParser.
func (*CSharpParser) Extensions ¶
func (p *CSharpParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*CSharpParser) TSLanguageForFile ¶
func (p *CSharpParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type CUEParser ¶
type CUEParser struct {
// contains filtered or unexported fields
}
CUEParser parses CUE (.cue) configuration files. It extracts package declarations, imports, definitions (#Name), top-level fields, and let bindings into graph nodes with appropriate types and metadata.
func (*CUEParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
type ClojureParser ¶
type ClojureParser struct{}
ClojureParser parses Clojure (.clj, .cljs, .cljc, .edn) source files. Used in data engineering, fintech backend systems, and JVM functional programming. Uses regex-based extraction (Clojure is not in go-tree-sitter).
Extracts:
- (defn fn-name [args] body) → NodeFunction (Exported: true)
- (defn- fn-name [args] body) → NodeFunction (Exported: false)
- (defn ^:private fn-name [args]) → NodeFunction (Exported: false)
- (defmacro name [args] body) → NodeFunction kind=macro
- (defmulti name dispatch-fn) → NodeFunction kind=multimethod
- (defmethod name dispatch-val [...]) → NodeFunction kind=multimethod
- (defrecord Name [fields]) → NodeStruct kind=record
- (defprotocol Name ...) → NodeStruct kind=protocol
- (deftype Name [fields]) → NodeStruct kind=type
- (ns my.namespace (:require [...])) → NodePackage + EdgeImports
- (require '[clojure.string :as str]) → NodePackage + EdgeImports
- (def var-name ...) → NodeVariable
- (def ^:private var-name ...) → NodeVariable (Exported: false)
func NewClojureParser ¶
func NewClojureParser() *ClojureParser
NewClojureParser creates a ready-to-use ClojureParser.
func (*ClojureParser) Extensions ¶
func (p *ClojureParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
type CppParser ¶
type CppParser struct {
// contains filtered or unexported fields
}
CppParser parses C++ source files.
func (*CppParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
type DartParser ¶
type DartParser struct{}
DartParser parses Dart (.dart) source files. Used in Flutter mobile apps, server-side Dart, and CLI tools. Uses regex-based extraction since Dart is not in go-tree-sitter.
func NewDartParser ¶
func NewDartParser() *DartParser
NewDartParser creates a ready-to-use DartParser.
func (*DartParser) Extensions ¶
func (p *DartParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
type DockerfileParser ¶
type DockerfileParser struct {
// contains filtered or unexported fields
}
DockerfileParser parses Dockerfile source files. It extracts build stages (FROM), COPY --from edges, ARG/ENV declarations, EXPOSE ports, LABEL metadata, and base image imports.
func NewDockerfileParser ¶
func NewDockerfileParser() *DockerfileParser
NewDockerfileParser creates a ready-to-use DockerfileParser.
func (*DockerfileParser) Extensions ¶
func (p *DockerfileParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*DockerfileParser) FilenamePrefixes ¶
func (p *DockerfileParser) FilenamePrefixes() []string
FilenamePrefixes returns filename prefixes that this parser handles. Any file whose base name starts with "Dockerfile" or "Containerfile" (e.g. Dockerfile.staging, Dockerfile.ci, Containerfile.dev) is parsed.
func (*DockerfileParser) Filenames ¶
func (p *DockerfileParser) Filenames() []string
Filenames returns the exact base filenames handled by this parser. These are files that have no extension (e.g. "Dockerfile") or use a dot-separated variant (e.g. "Dockerfile.dev"). The Walker checks this interface when no extension-based match is found.
func (*DockerfileParser) Parse ¶
Parse extracts code entities from a single Dockerfile and merges them into the graph.
Extracts:
- FROM stages -> NodeStruct with kind="stage"
- Base image imports -> EdgeImports to NodePackage
- COPY --from edges -> EdgeCalls between stages
- ARG declarations -> NodeVariable with kind="arg"
- ENV declarations -> NodeVariable with kind="env"
- EXPOSE ports -> metadata on file node
- LABEL metadata -> metadata on file node
func (*DockerfileParser) TSLanguageForFile ¶
func (p *DockerfileParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type ElixirParser ¶
type ElixirParser struct {
// contains filtered or unexported fields
}
ElixirParser parses Elixir (.ex, .exs) source files.
func NewElixirParser ¶
func NewElixirParser() *ElixirParser
NewElixirParser creates a ready-to-use ElixirParser.
func (*ElixirParser) Extensions ¶
func (p *ElixirParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*ElixirParser) TSLanguageForFile ¶
func (p *ElixirParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type ElmParser ¶
type ElmParser struct {
// contains filtered or unexported fields
}
ElmParser parses Elm (.elm) source files.
func (*ElmParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
type EntityCandidate ¶
type EntityCandidate struct {
Name string // extracted token (normalised, no backticks/quotes)
Context string // surrounding sentence (≤200 chars) for Tier 2
SourceLine int // 1-based line in the original markdown body
Confidence float64 // heuristic confidence: 0.6–0.95
}
EntityCandidate is a named entity extracted from natural-language text. Name is the raw extracted token; Context is the surrounding sentence for Tier 2 LLM classification. Confidence is a Tier 0 heuristic score.
func ExtractEntityCandidates ¶
func ExtractEntityCandidates(text string) []EntityCandidate
ExtractEntityCandidates scans markdown body text and returns entity candidates. Deduplicates by name (keeps highest confidence). Filters stop words and tokens shorter than 3 characters. Safe for concurrent use (no global state).
func ExtractFrontmatterCandidates ¶
func ExtractFrontmatterCandidates(tags []string, category string) []EntityCandidate
ExtractFrontmatterCandidates creates entity candidates from frontmatter metadata (tags and category) stored on file nodes. These have high confidence (0.95) since they are explicitly authored by the document owner.
type ErlangParser ¶
type ErlangParser struct{}
ErlangParser parses Erlang (.erl, .hrl) source files. Used in telecom, real-time distributed systems, and high-availability platforms. Uses regex-based extraction.
func NewErlangParser ¶
func NewErlangParser() *ErlangParser
NewErlangParser creates a ready-to-use ErlangParser.
func (*ErlangParser) Extensions ¶
func (p *ErlangParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
type FSharpParser ¶
type FSharpParser struct{}
FSharpParser parses F# (.fs, .fsi, .fsx) source files. Used heavily in fintech (.NET ecosystem), financial modeling, and functional teams. Uses regex-based extraction — F# is not in go-tree-sitter.
Extracts:
- Let bindings (functions and values) → NodeFunction
- Type definitions (records, DUs, aliases, interfaces, classes) → NodeStruct
- Module declarations → NodePackage
- open statements (imports) → NodePackage + EdgeImports
- Member methods inside types → NodeFunction (qualified)
- Active patterns → NodeFunction with kind=active_pattern
func NewFSharpParser ¶
func NewFSharpParser() *FSharpParser
NewFSharpParser creates a ready-to-use FSharpParser.
func (*FSharpParser) Extensions ¶
func (p *FSharpParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
type FilenameParser ¶
type FilenameParser interface {
Filenames() []string
}
FilenameParser is an optional interface that parsers can implement if they handle files matched by base filename rather than extension. The Walker checks this interface when no extension-based match is found.
type FilenamePatternParser ¶
type FilenamePatternParser interface {
FilenamePrefixes() []string
}
FilenamePatternParser is an optional interface for parsers that handle files whose base name matches a prefix (e.g. "Dockerfile" handles "Dockerfile.staging", "Dockerfile.ci", etc.).
type GoParser ¶
type GoParser struct {
// contains filtered or unexported fields
}
GoParser parses Go source files into graph nodes and edges using Tree-sitter.
func (*GoParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
func (*GoParser) Parse ¶
Parse extracts code entities from a single Go source file and merges them into the provided graph. The following constructs are captured:
- Package declarations → NodePackage
- Import declarations → NodeFile edges (IMPORTS)
- Function declarations → NodeFunction
- Method declarations → NodeMethod
- Type declarations (struct) → NodeStruct
- Type declarations (interface) → NodeInterface
- Type aliases and named types → NodeStruct (metadata kind=type_alias)
- Package-level const declarations → NodeVariable (metadata kind=const)
- Package-level var declarations → NodeVariable (metadata kind=var)
- Function/method call expressions → CALLS edges
Package-level var nodes use the line of the "var" keyword, not the line of any inferred type. For slice/map vars (var foo = []BarType{...}), the node name is "foo", the type is NodeVariable, and the element type does not affect classification (FIX-PARSER-2).
type GraphQLParser ¶
type GraphQLParser struct {
// contains filtered or unexported fields
}
GraphQLParser parses GraphQL (.graphql, .gql) schema and operation files using tree-sitter. Extracts type definitions, fields, enums, interfaces, unions, scalars, fragments, and directive definitions.
func NewGraphQLParser ¶
func NewGraphQLParser() *GraphQLParser
NewGraphQLParser creates a ready-to-use GraphQLParser.
func (*GraphQLParser) Extensions ¶
func (p *GraphQLParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*GraphQLParser) Parse ¶
Parse extracts code entities from a single GraphQL file and merges them into the graph.
func (*GraphQLParser) TSLanguageForFile ¶
func (p *GraphQLParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for the given file.
type GroovyParser ¶
type GroovyParser struct {
// contains filtered or unexported fields
}
GroovyParser parses Groovy (.groovy, .gradle) source files.
func NewGroovyParser ¶
func NewGroovyParser() *GroovyParser
NewGroovyParser creates a ready-to-use GroovyParser.
func (*GroovyParser) Extensions ¶
func (p *GroovyParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*GroovyParser) TSLanguageForFile ¶
func (p *GroovyParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type HCLParser ¶
type HCLParser struct {
// contains filtered or unexported fields
}
HCLParser parses HCL/Terraform (.tf, .tfvars, .hcl) source files. It extracts resource, data, module, variable, output, locals, provider, and terraform blocks into graph nodes with appropriate types and metadata.
func (*HCLParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
type HaskellParser ¶
type HaskellParser struct{}
HaskellParser parses Haskell (.hs, .lhs) source files. Used in fintech, compiler infrastructure, and functional programming teams. Uses regex-based extraction.
func NewHaskellParser ¶
func NewHaskellParser() *HaskellParser
NewHaskellParser creates a ready-to-use HaskellParser.
func (*HaskellParser) Extensions ¶
func (p *HaskellParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
type JSONParser ¶
type JSONParser struct {
// contains filtered or unexported fields
}
JSONParser parses JSON (.json) files with filename-aware depth control. Full deep parsing is performed for known high-value filenames (package.json, tsconfig.json, jsconfig.json, *.schema.json). All other JSON files get shallow top-level-key extraction only.
func NewJSONParser ¶
func NewJSONParser() *JSONParser
NewJSONParser creates a ready-to-use JSONParser.
func (*JSONParser) Extensions ¶
func (p *JSONParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*JSONParser) Parse ¶
Parse extracts code entities from a single JSON file and merges them into the graph.
Filename-aware strategy:
- package.json: deep parse (name, version, dependencies, scripts)
- tsconfig.json / jsconfig.json: compilerOptions and include/exclude
- *.schema.json / schema.json: $defs/definitions as NodeStruct, properties as NodeField
- all other .json: top-level keys as NodeField (1 level deep only)
func (*JSONParser) TSLanguageForFile ¶
func (p *JSONParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for the given file.
type JavaParser ¶
type JavaParser struct {
// contains filtered or unexported fields
}
JavaParser parses Java (.java) source files.
func NewJavaParser ¶
func NewJavaParser() *JavaParser
NewJavaParser creates a ready-to-use JavaParser.
func (*JavaParser) Extensions ¶
func (p *JavaParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*JavaParser) Parse ¶
Parse extracts code entities from a single Java file and merges them into the graph.
func (*JavaParser) TSLanguageForFile ¶
func (p *JavaParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type JavaScriptParser ¶
type JavaScriptParser struct {
// contains filtered or unexported fields
}
JavaScriptParser parses JavaScript (.js, .jsx, .mjs, .cjs) source files.
func NewJavaScriptParser ¶
func NewJavaScriptParser() *JavaScriptParser
NewJavaScriptParser creates a ready-to-use JavaScriptParser.
func (*JavaScriptParser) Extensions ¶
func (p *JavaScriptParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*JavaScriptParser) Parse ¶
Parse extracts code entities from a single JavaScript file and merges them into the provided graph. The following constructs are captured:
- Import declarations (ESM) → IMPORTS edges
- CommonJS require() calls → IMPORTS edges
- Function declarations → NodeFunction
- Arrow functions (named) → NodeFunction
- Method definitions → NodeMethod (class-qualified)
- Class declarations → NodeStruct
- Call expressions → call sites (resolved to CALLS edges)
func (*JavaScriptParser) TSLanguageForFile ¶
func (p *JavaScriptParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type JsonnetParser ¶
type JsonnetParser struct {
// contains filtered or unexported fields
}
JsonnetParser parses Jsonnet (.jsonnet, .libsonnet) source files. It extracts:
- Imports (local x = import 'path') → NodePackage + EdgeImports
- Local variables (local x = value) at file level → NodeVariable
- Object fields (field: value) → NodeVariable (exported)
- Hidden fields (field:: value) → NodeVariable (unexported)
- Function fields (field(params):: body) → NodeFunction
- Local functions inside objects (local f(x) = body) → NodeFunction
func NewJsonnetParser ¶
func NewJsonnetParser() *JsonnetParser
NewJsonnetParser creates a ready-to-use JsonnetParser.
func (*JsonnetParser) Extensions ¶
func (p *JsonnetParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*JsonnetParser) Parse ¶
Parse extracts code entities from a single Jsonnet file.
The Jsonnet grammar structures files as a chain of local_bind nodes:
local_bind → local + bind + ; + (next local_bind | object | expr)
The final expression in the chain is typically an object literal containing the exported fields and functions.
func (*JsonnetParser) TSLanguageForFile ¶
func (p *JsonnetParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for the given file.
type JuliaParser ¶
type JuliaParser struct {
// contains filtered or unexported fields
}
JuliaParser parses Julia (.jl) source files.
func NewJuliaParser ¶
func NewJuliaParser() *JuliaParser
NewJuliaParser creates a ready-to-use JuliaParser.
func (*JuliaParser) Extensions ¶
func (p *JuliaParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*JuliaParser) Parse ¶
Parse extracts code entities from a single Julia file and merges them into the graph.
func (*JuliaParser) TSLanguageForFile ¶
func (p *JuliaParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for the given file.
type KotlinParser ¶
type KotlinParser struct {
// contains filtered or unexported fields
}
KotlinParser parses Kotlin (.kt, .kts) source files.
func NewKotlinParser ¶
func NewKotlinParser() *KotlinParser
NewKotlinParser creates a ready-to-use KotlinParser.
func (*KotlinParser) Extensions ¶
func (p *KotlinParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*KotlinParser) TSLanguageForFile ¶
func (p *KotlinParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type LanguageParser ¶
type LanguageParser interface {
// Extensions returns the file extensions this parser handles (e.g. ".go").
Extensions() []string
// Parse extracts code entities from src and merges them into g.
Parse(g *graph.Graph, filePath string, src []byte) error
}
LanguageParser is implemented by each language-specific parser. Parse receives the raw source bytes and the file path; it appends discovered nodes and edges into the provided graph.
type LogicWarning ¶
type LogicWarning struct {
Check string `json:"check"` // check name, e.g. "zero_value_id"
File string `json:"file"` // file path
Line int `json:"line"` // 1-based line number
Message string `json:"message"` // human-readable description
Severity string `json:"severity"` // "warning"
}
LogicWarning represents a single heuristic logic warning found by AST analysis.
func RunLogicChecks ¶
func RunLogicChecks(filePath string, src []byte) []LogicWarning
RunLogicChecks parses the given source file and returns heuristic logic warnings. Only Go files are currently supported; other extensions return nil.
type LuaParser ¶
type LuaParser struct {
// contains filtered or unexported fields
}
LuaParser parses Lua (.lua) source files.
func (*LuaParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
type MATLABParser ¶
type MATLABParser struct{}
MATLABParser parses MATLAB/Octave source files (.m).
Extracts:
- classdef declarations → NodeStruct (with superclass edges)
- properties blocks → NodeVariable per property
- methods blocks → NodeFunction/NodeMethod per function_definition
- top-level function_definition → NodeFunction
func NewMATLABParser ¶
func NewMATLABParser() *MATLABParser
NewMATLABParser returns a new MATLAB parser.
func (*MATLABParser) Extensions ¶
func (p *MATLABParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*MATLABParser) Language ¶
func (p *MATLABParser) Language() string
Language returns the language name.
func (*MATLABParser) TSLanguageForFile ¶
func (p *MATLABParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type MakefileParser ¶
type MakefileParser struct {
// contains filtered or unexported fields
}
MakefileParser parses Makefile source files. It extracts variable assignments, build targets (rules), define directives, and include directives from GNU Make and compatible Makefiles.
func NewMakefileParser ¶
func NewMakefileParser() *MakefileParser
NewMakefileParser creates a ready-to-use MakefileParser.
func (*MakefileParser) Extensions ¶
func (p *MakefileParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*MakefileParser) Filenames ¶
func (p *MakefileParser) Filenames() []string
Filenames returns the exact base filenames handled by this parser. These are files that have no extension (e.g. "Makefile") or use standard naming conventions for GNU Make.
func (*MakefileParser) Parse ¶
Parse extracts code entities from a single Makefile and merges them into the graph.
Extracts:
- File node -> NodeFile
- Variable assignments -> NodeVariable with kind="variable"
- Rules/targets -> NodeFunction with kind="target"
- Define directives -> NodeFunction with kind="define"
- Include directives -> EdgeImports to NodePackage
func (*MakefileParser) TSLanguageForFile ¶
func (p *MakefileParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type MarkdownParser ¶
type MarkdownParser struct{}
MarkdownParser extracts structural sections from Markdown files (.md, .markdown, .mdx). Each ATX or setext heading becomes a Section node with CONTAINS edges forming a tree. Cross-document [text](path.md) links become LINKS_TO edges. Entity linking (EXPLAINS/DOCUMENTED_BY) is deferred to resolver.ResolveDocEdges which runs after all files are parsed, ensuring code entities are available.
Handles:
- ATX headings (# H1 through ###### H6) per CommonMark
- Setext headings (underline-style === and ---) per CommonMark
- YAML/TOML frontmatter (--- block at top of file) is skipped
- Headings inside fenced code blocks (``` or ~~~) are skipped
- Duplicate heading titles disambiguated with counter suffix
func NewMarkdownParser ¶
func NewMarkdownParser() *MarkdownParser
NewMarkdownParser returns a parser for Markdown documentation files.
func (*MarkdownParser) Extensions ¶
func (p *MarkdownParser) Extensions() []string
Extensions returns the file extensions handled by MarkdownParser.
type NixParser ¶
type NixParser struct {
// contains filtered or unexported fields
}
NixParser parses Nix (.nix) expression files. It extracts let bindings, attribute set keys, function parameters, and import expressions into graph nodes. Nix is a pure functional language for the Nix package manager — its main entities are bindings and derivations rather than traditional functions/classes.
func (*NixParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
type OCamlParser ¶
type OCamlParser struct {
// contains filtered or unexported fields
}
OCamlParser parses OCaml (.ml, .mli) source files.
func NewOCamlParser ¶
func NewOCamlParser() *OCamlParser
NewOCamlParser creates a ready-to-use OCamlParser.
func (*OCamlParser) Extensions ¶
func (p *OCamlParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*OCamlParser) TSLanguageForFile ¶
func (p *OCamlParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type ObjCParser ¶
type ObjCParser struct {
// contains filtered or unexported fields
}
ObjCParser parses Objective-C (.m, .h) source files.
Extracted entities:
- @interface blocks → NodeStruct (classes) with superclass and protocol metadata
- Method declarations inside @interface → NodeMethod with selector and scope metadata
- @property declarations inside @interface → NodeMethod (kind=property)
- @protocol declarations → NodeInterface
- Method declarations inside @protocol → NodeMethod
- @implementation blocks → NodeStruct (if not already from @interface) + methods
- #import / #include directives → NodePackage with EdgeImports
NS_ENUM / typedef enum are not extracted (complex to parse cleanly from tree-sitter).
func NewObjCParser ¶
func NewObjCParser() *ObjCParser
NewObjCParser creates a ready-to-use ObjCParser.
func (*ObjCParser) Extensions ¶
func (p *ObjCParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*ObjCParser) Parse ¶
Parse extracts code entities from a single Objective-C file and merges them into the graph.
func (*ObjCParser) TSLanguageForFile ¶
func (p *ObjCParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for the given file.
type PHPParser ¶
type PHPParser struct {
// contains filtered or unexported fields
}
PHPParser parses PHP (.php) source files.
func (*PHPParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
type PerlParser ¶
type PerlParser struct{}
PerlParser parses Perl source files (.pl, .pm, .t).
Extracts:
- package declarations → NodePackage
- subroutine declarations → NodeFunction (exported if name doesn't start with _)
- our/my variable declarations at file scope → NodeVariable
- use statements (imports) → NodePackage edges
func (*PerlParser) Extensions ¶
func (p *PerlParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*PerlParser) Language ¶
func (p *PerlParser) Language() string
Language returns the language name.
func (*PerlParser) TSLanguageForFile ¶
func (p *PerlParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type PlaintextParser ¶
type PlaintextParser struct{}
PlaintextParser extracts structural sections from plain text (.txt) and reStructuredText (.rst) files. Like MarkdownParser, each detected heading becomes a Section node with CONTAINS edges forming a tree.
RST heading detection follows the docutils spec: a text line followed by an underline of repeated punctuation characters (=, -, ~, ^, ", #, +, *, .) where the underline is at least as long as the text. An optional overline (same character) promotes the heading. Heading depth is assigned by the order in which underline characters first appear in the file.
TXT heading detection uses heuristics:
- ALL-CAPS lines of 3+ characters → depth 1
- Lines ending with ":" preceded by a blank line → depth 2
- Fallback: double-blank-line separated paragraphs → depth 1
func NewPlaintextParser ¶
func NewPlaintextParser() *PlaintextParser
NewPlaintextParser returns a parser for plaintext and RST documentation files.
func (*PlaintextParser) Extensions ¶
func (p *PlaintextParser) Extensions() []string
Extensions returns the file extensions handled by PlaintextParser.
type PluginChecker ¶
type PluginChecker struct {
// contains filtered or unexported fields
}
PluginChecker validates whether a plugin command is allowed to execute. It reads the allowlist from the user's home directory (~/.synapses/).
func NewPluginChecker ¶
func NewPluginChecker(synapsesDir string) *PluginChecker
NewPluginChecker creates a checker that reads allowlists from synapsesDir. synapsesDir is typically ~/.synapses.
func (*PluginChecker) ApproveCommand ¶
func (pc *PluginChecker) ApproveCommand(command string) error
ApproveCommand adds a command to the per-machine allowlist.
func (*PluginChecker) IsAllowed ¶
func (pc *PluginChecker) IsAllowed(command string) error
IsAllowed checks whether a plugin command is approved for execution. Returns nil if allowed, a descriptive error if not.
func (*PluginChecker) ListApproved ¶
func (pc *PluginChecker) ListApproved() map[string]string
ListApproved returns all currently approved commands.
func (*PluginChecker) RevokeCommand ¶
func (pc *PluginChecker) RevokeCommand(command string) error
RevokeCommand removes a command from the per-machine allowlist.
type PluginParser ¶
type PluginParser struct {
// contains filtered or unexported fields
}
PluginParser implements LanguageParser by spawning an external process. One process is spawned per file; the process lifetime is bounded by pluginTimeout.
func (*PluginParser) Extensions ¶
func (p *PluginParser) Extensions() []string
Extensions implements LanguageParser.
type PowerShellParser ¶
type PowerShellParser struct{}
PowerShellParser parses PowerShell (.ps1, .psm1, .psd1) source files. Uses regex-based extraction since PowerShell is not in go-tree-sitter.
func NewPowerShellParser ¶
func NewPowerShellParser() *PowerShellParser
NewPowerShellParser creates a ready-to-use PowerShellParser.
func (*PowerShellParser) Extensions ¶
func (p *PowerShellParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
type ProtobufParser ¶
type ProtobufParser struct{}
ProtobufParser parses Protocol Buffer (.proto) source files using github.com/emicklei/proto — a dedicated proto parser that handles oneof blocks, nested messages, and enum values correctly without producing [ERROR] nodes (the fundamental limitation of the tree-sitter proto grammar).
func NewProtobufParser ¶
func NewProtobufParser() *ProtobufParser
NewProtobufParser creates a ready-to-use ProtobufParser.
func (*ProtobufParser) Extensions ¶
func (p *ProtobufParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
type PythonParser ¶
type PythonParser struct {
// contains filtered or unexported fields
}
PythonParser parses Python (.py, .pyi) source files.
func NewPythonParser ¶
func NewPythonParser() *PythonParser
NewPythonParser creates a ready-to-use PythonParser.
func (*PythonParser) Extensions ¶
func (p *PythonParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*PythonParser) Parse ¶
Parse extracts code entities from a single Python file and merges them into the provided graph.
func (*PythonParser) TSLanguageForFile ¶
func (p *PythonParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type RBSParser ¶
type RBSParser struct{}
RBSParser parses Ruby RBS type signature files (.rbs). RBS files use a dedicated syntax (not Ruby) so we parse them line-by-line rather than using the tree-sitter Ruby grammar. We emit classes, modules, interfaces, and method signatures as graph nodes.
func (*RBSParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
func (*RBSParser) Parse ¶
Parse extracts code entities from a single RBS file. RBS syntax examples:
class Foo < Bar → NodeStruct module Baz → NodeInterface interface _Iterator[T] → NodeInterface with kind="interface" def initialize: (String) -> void → NodeMethod def self.create: (Integer) -> Foo → NodeMethod with kind="singleton" type alias_name = Integer → NodeStruct with kind="alias"
type RParser ¶
type RParser struct{}
RParser parses R (.r, .R) source files. Used extensively in data science, statistics, bioinformatics, finance, and pharma. Uses regex-based extraction since R is not in go-tree-sitter.
Extracts:
- Function assignments (<-, =, <<-) → NodeFunction
- S3 generic functions (summary.myClass) → NodeFunction with kind=s3generic
- S4 setClass() → NodeStruct with kind=s4class
- S4 setGeneric() → NodeFunction with kind=s4generic
- S4 setMethod() → NodeFunction with kind=s4method
- R5/Reference classes (setRefClass) → NodeStruct with kind=r5class
- library()/require() imports → NodePackage + EdgeImports
- Namespace pkg::func references → EdgeImports
func (*RParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
type RelationshipSignal ¶
type RelationshipSignal struct {
From string
To string
Signal string // e.g. "depends on", "implements", "uses"
SourceLine int
}
RelationshipSignal is a keyword-based relationship hint extracted from text. From and To are candidate names; Signal is the relationship keyword found. These are upgraded to typed EdgeType values by Tier 1/2 resolution.
func ExtractRelationshipSignals ¶
func ExtractRelationshipSignals(text string, candidates []EntityCandidate) []RelationshipSignal
ExtractRelationshipSignals scans text for explicit relationship keywords and returns relationship signals between adjacent entity candidates. Best-effort: only fires when a relationship keyword appears between two recognisable entity-like tokens on the same line.
type RouteRegistration ¶
type RouteRegistration struct {
File string
Line int // 1-based line number of the registration call
Method string // HTTP method ("GET", "POST", …) or "*" for wildcard
Path string // URL path e.g. "/api/users"
Handler string // handler function name
EnclosingFn string // function/method that contains the registration call
Confidence float64
}
RouteRegistration holds a single detected route registration.
func ExtractRouteRegistrations ¶
func ExtractRouteRegistrations(filePath string, src []byte) []RouteRegistration
ExtractRouteRegistrations scans src for handler registration patterns and returns a slice of RouteRegistration describing each match. filePath is used to select the right language-specific patterns.
type RubyParser ¶
type RubyParser struct {
// contains filtered or unexported fields
}
RubyParser parses Ruby (.rb) source files.
func NewRubyParser ¶
func NewRubyParser() *RubyParser
NewRubyParser creates a ready-to-use RubyParser.
func (*RubyParser) Extensions ¶
func (p *RubyParser) Extensions() []string
Extensions returns the file extensions handled by this parser. .rbi files are Sorbet type stubs — they use Ruby syntax, so the same tree-sitter Ruby grammar handles them correctly.
func (*RubyParser) TSLanguageForFile ¶
func (p *RubyParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type RustParser ¶
type RustParser struct {
// contains filtered or unexported fields
}
RustParser parses Rust (.rs) source files.
func NewRustParser ¶
func NewRustParser() *RustParser
NewRustParser creates a ready-to-use RustParser.
func (*RustParser) Extensions ¶
func (p *RustParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*RustParser) Parse ¶
Parse extracts code entities from a single Rust file and merges them into the graph.
func (*RustParser) TSLanguageForFile ¶
func (p *RustParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type SCSSParser ¶
type SCSSParser struct{}
SCSSParser parses SCSS and Sass (.scss, .sass) source files using regex.
Extracts:
- @mixin name(params) { } → NodeFunction with kind="mixin"
- @function name(params) { } → NodeFunction with kind="function"
- $variable: value; → NodeVariable with kind="variable"
- %placeholder { } → NodeStruct with kind="placeholder"
- Top-level .class, #id, and %placeholder selectors → NodeStruct with kind="selector"
- Multiple selectors on one line (.a, .b { }) → each extracted separately
- @use / @forward / @import → EdgeImports to NodePackage nodes
- @include mixin-name → AddCallSite for cross-file resolution + direct EdgeCalls for same-file mixins
- @extend .selector / %placeholder → EdgeCalls to extended node
func NewSCSSParser ¶
func NewSCSSParser() *SCSSParser
NewSCSSParser creates a ready-to-use SCSSParser.
func (*SCSSParser) Extensions ¶
func (p *SCSSParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
type SQLParser ¶
type SQLParser struct {
// contains filtered or unexported fields
}
SQLParser parses SQL (.sql) source files, extracting CREATE TABLE, VIEW, FUNCTION, PROCEDURE, TRIGGER, and INDEX declarations as graph nodes.
func (*SQLParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
func (*SQLParser) Parse ¶
Parse extracts code entities from a single SQL file and merges them into the graph.
Strategy: tree-sitter SQL grammars vary widely in their node types across versions. Instead of relying on specific statement types, we walk the AST recursively and inspect the source text of each node for CREATE keywords. This makes the parser resilient to grammar changes while still leveraging tree-sitter for accurate statement boundary detection.
type ScalaParser ¶
type ScalaParser struct {
// contains filtered or unexported fields
}
ScalaParser parses Scala (.scala) source files.
func NewScalaParser ¶
func NewScalaParser() *ScalaParser
NewScalaParser creates a ready-to-use ScalaParser.
func (*ScalaParser) Extensions ¶
func (p *ScalaParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*ScalaParser) TSLanguageForFile ¶
func (p *ScalaParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type SolidityParser ¶
type SolidityParser struct {
// contains filtered or unexported fields
}
SolidityParser parses Solidity (.sol) source files.
func NewSolidityParser ¶
func NewSolidityParser() *SolidityParser
NewSolidityParser creates a ready-to-use SolidityParser.
func (*SolidityParser) Extensions ¶
func (p *SolidityParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*SolidityParser) Parse ¶
Parse extracts code entities from a single Solidity file and merges them into the graph.
func (*SolidityParser) TSLanguageForFile ¶
func (p *SolidityParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for the given file.
type StarlarkParser ¶
type StarlarkParser struct {
// contains filtered or unexported fields
}
StarlarkParser parses Starlark/Bazel (.bzl, .star, BUILD, WORKSPACE) files. It extracts function definitions, build targets, load() imports, and top-level variable assignments.
func NewStarlarkParser ¶
func NewStarlarkParser() *StarlarkParser
NewStarlarkParser creates a ready-to-use StarlarkParser.
func (*StarlarkParser) Extensions ¶
func (p *StarlarkParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*StarlarkParser) Filenames ¶
func (p *StarlarkParser) Filenames() []string
Filenames returns the exact base filenames handled by this parser.
func (*StarlarkParser) Parse ¶
Parse extracts code entities from a single Starlark/Bazel file and merges them into the graph.
Extracts:
- File node (NodeFile)
- function_definition -> NodeFunction
- Top-level call to known rule function -> NodeStruct with kind="target"
- load() calls -> EdgeImports for each loaded symbol
- Top-level assignments -> NodeVariable
func (*StarlarkParser) TSLanguageForFile ¶
func (p *StarlarkParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type SvelteParser ¶
type SvelteParser struct{}
SvelteParser parses Svelte (.svelte) single-file components.
Extracts:
- Script block imports (import X from 'module') → EdgeImports
- Component imports (import Comp from './Comp.svelte') → EdgeImports
- Exported variables (export let propName) → NodeVariable with kind="prop"
- Reactive declarations ($: computed = ...) → NodeVariable with kind="reactive"
- Function declarations (function name() {}) → NodeFunction
- Script-level const/let variables → NodeVariable
- Svelte component usage (<Component />) → EdgeCalls
func NewSvelteParser ¶
func NewSvelteParser() *SvelteParser
NewSvelteParser creates a ready-to-use SvelteParser.
func (*SvelteParser) Extensions ¶
func (p *SvelteParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
type SwiftParser ¶
type SwiftParser struct {
// contains filtered or unexported fields
}
SwiftParser parses Swift (.swift) source files.
func NewSwiftParser ¶
func NewSwiftParser() *SwiftParser
NewSwiftParser creates a ready-to-use SwiftParser.
func (*SwiftParser) Extensions ¶
func (p *SwiftParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*SwiftParser) Parse ¶
Parse extracts code entities from a single Swift file and merges them into the graph.
func (*SwiftParser) TSLanguageForFile ¶
func (p *SwiftParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type TOMLParser ¶
type TOMLParser struct {
// contains filtered or unexported fields
}
TOMLParser parses TOML (.toml) configuration files. It extracts sections (tables), array-of-tables, and key-value pairs into graph nodes. Special handling is provided for dependency sections commonly found in Cargo.toml, pyproject.toml, etc.
func NewTOMLParser ¶
func NewTOMLParser() *TOMLParser
NewTOMLParser creates a ready-to-use TOMLParser.
func (*TOMLParser) Extensions ¶
func (p *TOMLParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*TOMLParser) Parse ¶
Parse extracts code entities from a single TOML file and merges them into the graph.
Extraction rules:
- [section] headers → NodeStruct with kind=table
- [[array]] headers → NodeStruct with kind=array_table
- Top-level pair nodes (before any section) → NodeField with kind=field
- For [dependencies] / [dev-dependencies] / [build-dependencies]: each pair also emits a NodeField with kind=dependency
- Dotted keys like [profile.release] → name = "profile.release"
func (*TOMLParser) TSLanguageForFile ¶
func (p *TOMLParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for the given file.
type TerraformParser ¶
type TerraformParser struct {
// contains filtered or unexported fields
}
TerraformParser parses HashiCorp Configuration Language (.tf) files. It extracts Terraform resources, data sources, modules, variables, outputs, locals, and providers as graph nodes, and records TerraformRefs for cross-file DEPENDS_ON resolution (resolved post-parse by ResolveTerraformRefs).
func NewTerraformParser ¶
func NewTerraformParser() *TerraformParser
NewTerraformParser creates a ready-to-use TerraformParser.
func (*TerraformParser) Extensions ¶
func (p *TerraformParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*TerraformParser) Parse ¶
Parse extracts Terraform entities from a single .tf file and merges them into g.
Node mapping:
- resource → NodeStruct (name: "resource_type.resource_name")
- data → NodeStruct (name: "data.resource_type.resource_name")
- module → NodePackage (name: "module.label")
- variable → NodeVariable (name: "var.label")
- output → NodeVariable (name: "output.label")
- locals → NodeVariable (name: "local.key") per key in the block
- provider → NodeStruct (name: "provider.label")
All nodes carry Domain=DomainInfra and metadata domain="terraform", kind=<type>. Resource references found in attribute expressions are recorded as TerraformRefs for cross-file DEPENDS_ON resolution by ResolveTerraformRefs (resolver package).
func (*TerraformParser) TSLanguageForFile ¶
func (p *TerraformParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile implements TreeSitterLanguageProvider so the watcher can pre-check .tf files for parse errors during active editing.
type ThriftParser ¶
type ThriftParser struct {
// contains filtered or unexported fields
}
ThriftParser parses Apache Thrift IDL (.thrift) source files.
Extracted entities:
- namespace declarations → NodePackage (kind=namespace, metadata lang=<scope>)
- typedef definitions → NodeMethod (kind=typedef, metadata alias=<original_type>)
- enum definitions → NodeStruct (kind=enum) + enum value identifiers → NodeMethod
- struct definitions → NodeStruct (kind=struct) + fields → NodeMethod (kind=field)
- exception definitions → NodeStruct (kind=exception) + fields → NodeMethod (kind=field)
- union definitions → NodeStruct (kind=union) + fields → NodeMethod (kind=field)
- const definitions → NodeMethod (kind=const, metadata type=<type>)
- service definitions → NodeInterface (kind=service) + function_definition → NodeMethod
All top-level Thrift definitions are Exported=true (IDL is a public interface by definition).
AST node types verified via TestProbeThrift:
document → top-level container
namespace_declaration: [namespace][namespace_scope][namespace]
typedef_definition: [typedef][definition_type][typedef_identifier]
enum_definition: [enum][identifier]{[identifier][=][number][,]...}
struct_definition: [struct][identifier]{[field]...}
exception_definition: [exception][identifier]{[field]...}
service_definition: [service][identifier]{[function_definition]...}
union_definition: [union][identifier]{[field]...}
const_definition: [const][definition_type][identifier][=][literal]
field: [field_id][field_modifier?][type][identifier][,?]
function_definition: [type][identifier][parameters][throws?][,?]
func NewThriftParser ¶
func NewThriftParser() *ThriftParser
NewThriftParser creates a ready-to-use ThriftParser.
func (*ThriftParser) Extensions ¶
func (p *ThriftParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*ThriftParser) Parse ¶
Parse extracts code entities from a single Thrift IDL file and merges them into the graph.
func (*ThriftParser) TSLanguageForFile ¶
func (p *ThriftParser) TSLanguageForFile(_ string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for the given file.
type TreeSitterLanguageProvider ¶
TreeSitterLanguageProvider is an optional interface for parsers that use tree-sitter internally. Returning the language enables the watcher to pre-check files for parse errors before updating the graph, preventing corrupted ASTs from half-saved files during active editing.
type TypeScriptParser ¶
type TypeScriptParser struct {
// contains filtered or unexported fields
}
TypeScriptParser parses TypeScript (.ts) and TSX (.tsx) source files.
func NewTypeScriptParser ¶
func NewTypeScriptParser() *TypeScriptParser
NewTypeScriptParser creates a ready-to-use TypeScriptParser.
func (*TypeScriptParser) Extensions ¶
func (p *TypeScriptParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*TypeScriptParser) Parse ¶
Parse extracts code entities from a single TypeScript/TSX file and merges them into the provided graph.
func (*TypeScriptParser) TSLanguageForFile ¶
func (p *TypeScriptParser) TSLanguageForFile(filePath string) *sitter.Language
TSLanguageForFile returns the tree-sitter language for this parser.
type VueParser ¶
type VueParser struct {
// contains filtered or unexported fields
}
VueParser parses Vue Single-File Components (.vue files).
Extracts:
- A component node (NodeStruct, kind=component) named after the filename
- Script block content re-parsed via JS or TS sub-parser for functions, classes, imports, variables, etc.
- Style block metadata (scoped flag, language)
The Vue grammar provides raw_text for script/style content rather than a parsed AST, so script content is delegated to the JS/TS sub-parsers.
func (*VueParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
type Walker ¶
type Walker struct {
// BeginFunc is called once, on the main goroutine, after the filesystem
// scan completes and the total file count is known, but before any parsing
// begins. Use this to initialise progress state with the real total.
// Set to nil to disable.
BeginFunc func(total int)
// ProgressFunc is called from worker goroutines after each file is parsed.
// done is the number of files completed so far; total is the same value
// passed to BeginFunc. byExt maps file extension (e.g. ".go") to the
// number of files of that type parsed so far (snapshot copy — safe to read
// without locking). Calls are throttled to at most 1 per 200ms via an
// atomic CAS; the final call (done==total) always fires.
// The callback is called from multiple goroutines; implementations must be
// goroutine-safe. Set to nil to disable progress reporting.
ProgressFunc func(done, total int, byExt map[string]int)
// PulseClient, when non-nil, receives a ParseEvent after each file is
// parsed during WalkDir. Fire-and-forget — never blocks parsing. (P2-2)
PulseClient *pulse.Client
// ProjectID is included in ParseEvent so Pulse can scope data per project.
ProjectID string
// Throttle reduces parsing concurrency to half the normal worker count
// and lowers the OS scheduling priority (nice +10). Use this for the
// initial full-index so the machine stays responsive during the first
// impression — incremental updates are already fast and don't need this.
Throttle bool
// contains filtered or unexported fields
}
Walker orchestrates multi-language parsing over a directory tree.
func NewWalker ¶
func NewWalker() *Walker
NewWalker creates a Walker pre-loaded with all built-in language parsers. Registration order matters: generic (file-only) is registered first so that dedicated AST parsers registered afterward take precedence for their extensions.
func (*Walker) HasParseErrors ¶
HasParseErrors performs a lightweight tree-sitter parse of src and returns true if the resulting AST contains syntax errors. Used by the watcher to skip reparsing files that are mid-save (half-written), preventing corrupted AST data from replacing valid graph nodes.
Returns false for parsers that don't use tree-sitter or for unknown extensions.
func (*Walker) IncrementalReindex ¶
func (w *Walker) IncrementalReindex(g *graph.Graph, root string, known map[string]int64) (fresh map[string]int64, changed, removed int, err error)
IncrementalReindex re-parses only files whose modification time has changed since the last full index. g must be a fully-populated graph (e.g. loaded from SQLite). known maps absolute path → UnixNano mtime from the last index.
Returns: fresh mtime map (all current parseable files), # changed/new files, # removed files (deleted from disk since last index).
Note: CALLS edges from unchanged files that point INTO re-parsed files may be lost if the re-parsed file's node IDs changed. Run a full reindex if perfect edge fidelity is required.
func (*Walker) ParseFile ¶
ParseFile parses a single file and updates g. If the file extension is not supported it returns nil without error.
func (*Walker) ParseFileSrc ¶
ParseFileSrc parses a single file from pre-read bytes and updates g. It is identical to ParseFile but skips the os.ReadFile call, allowing callers that already hold the file bytes (e.g. for error checking or content hashing) to avoid a second disk read. If the file extension is not supported it returns nil without error.
func (*Walker) Register ¶
func (w *Walker) Register(p LanguageParser)
Register adds a language parser. If two parsers claim the same extension the last one registered wins.
func (*Walker) RegisterPlugin ¶
func (w *Walker) RegisterPlugin(extensions []string, command string, checker *PluginChecker)
RegisterPlugin adds an external parser plugin for the given file extensions. command is split on whitespace into binary + args (e.g. "node parsers/graphql.js"). If two parsers claim the same extension the last one registered wins, so plugins registered here override built-in parsers for their extensions.
If checker is non-nil, the command is validated against the per-machine allowlist before registration. Unapproved plugins are skipped with a stderr warning.
func (*Walker) WalkDir ¶
WalkDir recursively parses all supported files under root and populates g. It skips hidden directories (prefixed with ".") and common non-source dirs. Returns a map of absolute file path → modification time (UnixNano) for every file that was successfully (or non-fatally) parsed. This map can be persisted to the store and used by IncrementalReindex on subsequent runs.
Parsing is parallelised across min(runtime.NumCPU(), 8) workers. All language parsers create a fresh sitter.Parser per call so there is no shared mutable state between goroutines. Graph mutations are protected by Graph's own mutex.
type XMLParser ¶
type XMLParser struct {
// contains filtered or unexported fields
}
XMLParser parses XML files (.xml) using tree-sitter. It performs schema-aware extraction based on filename:
- pom.xml (Maven): project identity, dependencies, plugins, modules
- AndroidManifest.xml: activities, services, receivers, permissions
- *context.xml / *config.xml (Spring): beans, imports
- Generic XML: root element, direct children with id/name attributes
func (*XMLParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
type YAMLParser ¶
type YAMLParser struct{}
YAMLParser parses YAML (.yaml, .yml) files. Covers Kubernetes manifests, Docker Compose, GitHub Actions, Ansible, Helm, OpenAPI, and general config. Uses gopkg.in/yaml.v3 for proper AST-level parsing (not regex).
func NewYAMLParser ¶
func NewYAMLParser() *YAMLParser
NewYAMLParser creates a ready-to-use YAMLParser.
func (*YAMLParser) Extensions ¶
func (p *YAMLParser) Extensions() []string
Extensions returns the file extensions handled by this parser.
func (*YAMLParser) Parse ¶
Parse extracts code entities from a single YAML file and merges them into the graph.
It handles multi-document YAML (--- separated) and is schema-aware for:
- Kubernetes manifests (kind + metadata.name)
- Docker Compose (services)
- GitHub Actions (jobs, on triggers)
- Ansible playbooks (top-level tasks with name field)
General extraction:
- Top-level keys → NodeVariable with kind=key
- YAML anchors (&name) → NodeVariable with kind=anchor
- String values matching *.yaml or *.yml → EdgeImports
type ZigParser ¶
type ZigParser struct {
// contains filtered or unexported fields
}
ZigParser parses Zig (.zig) source files.
func (*ZigParser) Extensions ¶
Extensions returns the file extensions handled by this parser.
Source Files
¶
- bash.go
- bicep.go
- c.go
- clojure.go
- cmake.go
- cpp.go
- csharp.go
- css.go
- cue.go
- dart.go
- disambiguate.go
- dockerfile.go
- elixir.go
- elm.go
- erlang.go
- fsharp.go
- generic.go
- golang.go
- graphql.go
- groovy.go
- haskell.go
- hcl.go
- heuristic.go
- java.go
- javascript.go
- json.go
- jsonnet.go
- julia.go
- kotlin.go
- logic_checks.go
- lua.go
- makefile.go
- markdown.go
- matlab.go
- metadata.go
- nix.go
- nl_extract.go
- objc.go
- ocaml.go
- parser.go
- perl.go
- php.go
- plaintext.go
- plugin.go
- plugin_allowlist.go
- powershell.go
- priority_unix.go
- protobuf.go
- provenance.go
- python.go
- r.go
- ruby.go
- rust.go
- scala.go
- scss.go
- solidity.go
- sql.go
- starlark.go
- svelte.go
- swift.go
- terraform.go
- thrift.go
- timeout.go
- toml.go
- typescript.go
- vue.go
- xml.go
- yaml.go
- zig.go