graph

package
v0.12.17 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AffectedFile

type AffectedFile struct {
	File  string     `json:"file"`
	Kind  ChangeKind `json:"kind"`
	Nodes []*Node    `json:"nodes"`
}

type Arch

type Arch struct {
	Languages   []LangStat   `json:"languages"`
	TotalFiles  int          `json:"total_files"`
	TotalNodes  int          `json:"total_nodes"`
	TotalEdges  int          `json:"total_edges"`
	Layers      []ModuleStat `json:"layers"`
	Modules     []ModuleStat `json:"modules"`
	ModuleDeps  []ModuleDep  `json:"module_deps"`
	EntryPoints []*Node      `json:"entry_points"`
	Hotspots    []Hotspot    `json:"hotspots"`
}

type CallResolver

type CallResolver interface {
	ResolveCall(ctx context.Context, file string, line, column int) (defFile string, defLine int, ok bool)
}

type ChangeKind

type ChangeKind string
const (
	ChangeAdded    ChangeKind = "added"
	ChangeModified ChangeKind = "modified"
	ChangeDeleted  ChangeKind = "deleted"
)

type Changes

type Changes struct {
	Files  []AffectedFile `json:"files"`
	Impact []Impact       `json:"impact,omitempty"`
}

type CoChange

type CoChange struct {
	File  string `json:"file"`
	Count int    `json:"count"`
}

type CoChangesResult

type CoChangesResult struct {
	File    string     `json:"file"`
	Commits int        `json:"commits"`
	Related []CoChange `json:"related"`
}

type ContentHit added in v0.12.7

type ContentHit struct {
	Node       *Node `json:"node"`
	MatchLines []int `json:"match_lines"`
	Callers    int   `json:"callers"`
	Callees    int   `json:"callees"`
	Score      int   `json:"score"`
}

type ContentSearchOpts added in v0.12.7

type ContentSearchOpts struct {
	Pattern    string
	Regex      bool
	IgnoreCase bool
	File       string
	Glob       string
	Limit      int
	Offset     int
}

type ContentSearchResult added in v0.12.7

type ContentSearchResult struct {
	Hits            []ContentHit    `json:"hits"`
	Raw             []RawContentHit `json:"raw,omitempty"`
	TotalLineHits   int             `json:"total_line_hits"`
	TotalResults    int             `json:"total_results"`
	TotalRawResults int             `json:"total_raw_results"`
	Offset          int             `json:"offset"`
	HasMore         bool            `json:"has_more"`
	RawHasMore      bool            `json:"raw_has_more"`
}

type CoverageIssue added in v0.12.7

type CoverageIssue struct {
	File   string `json:"file"`
	Reason string `json:"reason"`
}

CoverageIssue records a source file that discovery found but the structural index could not fully process. Content search still scans these files and returns their hits as raw matches.

type DepsResult

type DepsResult struct {
	Module     string   `json:"module"`
	DependsOn  []string `json:"depends_on"`
	DependedBy []string `json:"depended_by"`
	External   []string `json:"external"`
	Transitive []string `json:"transitive,omitempty"`
}

type Edge

type Edge struct {
	From string     `json:"from"`
	To   string     `json:"to"`
	Kind EdgeKind   `json:"kind"`
	Via  Provenance `json:"via,omitempty"`
}

type EdgeKind

type EdgeKind string
const (
	EdgeCalls      EdgeKind = "calls"
	EdgeInherits   EdgeKind = "inherits"
	EdgeImplements EdgeKind = "implements"
)

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func New

func New(root, cachePath string, opts ...Option) *Engine

func (*Engine) Architecture

func (e *Engine) Architecture(ctx context.Context) (Arch, error)

func (*Engine) CoChanges

func (e *Engine) CoChanges(ctx context.Context, file string, limit int) (CoChangesResult, error)

func (*Engine) DeadCode

func (e *Engine) DeadCode(ctx context.Context, limit int) ([]*Node, error)

func (*Engine) Deps

func (e *Engine) Deps(ctx context.Context, target string, depth int) (DepsResult, error)

func (*Engine) DetectChanges

func (e *Engine) DetectChanges(ctx context.Context, since string) (Changes, error)

func (*Engine) EdgeStats

func (e *Engine) EdgeStats() map[Provenance]int

func (*Engine) Hierarchy

func (e *Engine) Hierarchy(ctx context.Context, name, file string) (HierarchyResult, error)

func (*Engine) Index

func (e *Engine) Index(ctx context.Context) (Status, error)

func (*Engine) IsStale added in v0.12.7

func (e *Engine) IsStale(ctx context.Context) bool

IsStale reports whether the cached graph's discovered source-file set or any file's size/mtime differs from the workspace. A false result when no graph exists means "not indexed", not "fresh".

func (*Engine) Search

func (e *Engine) Search(ctx context.Context, opts SearchOpts) ([]*Node, error)

func (*Engine) SearchContent added in v0.12.7

func (e *Engine) SearchContent(ctx context.Context, opts ContentSearchOpts) (ContentSearchResult, error)

SearchContent scans the graph's discovered source-file set, maps each matching line to the tightest containing definition, and deduplicates the result by definition. Matches outside graph coverage remain in Raw.

func (*Engine) SearchPage added in v0.12.7

func (e *Engine) SearchPage(ctx context.Context, opts SearchOpts) (SearchResult, error)

func (*Engine) Similar

func (e *Engine) Similar(ctx context.Context, name, file string, limit int) (SimilarResult, error)

func (*Engine) Snippet

func (e *Engine) Snippet(ctx context.Context, name, file string) (Snippet, error)

func (*Engine) Status

func (e *Engine) Status() Status

func (*Engine) StatusOrLoad

func (e *Engine) StatusOrLoad() Status

func (*Engine) Tests

func (e *Engine) Tests(ctx context.Context, name, file string) (TestsResult, error)

func (*Engine) Trace

func (e *Engine) Trace(ctx context.Context, from, to, file string, callers bool, maxDepth int) (TraceResult, error)

type Graph

type Graph struct {
	Nodes   []*Node   `json:"nodes"`
	Edges   []*Edge   `json:"edges"`
	Imports []*Import `json:"imports,omitempty"`
	// contains filtered or unexported fields
}

type HierarchyResult

type HierarchyResult struct {
	Type         *Node   `json:"type"`
	Extends      []*Node `json:"extends"`
	Subtypes     []*Node `json:"subtypes"`
	Implements   []*Node `json:"implements"`
	Implementers []*Node `json:"implementers"`
	Others       []*Node `json:"others,omitempty"`
}

type Hotspot

type Hotspot struct {
	Node    *Node `json:"node"`
	Callers int   `json:"callers"`
	Callees int   `json:"callees"`
}

type Impact added in v0.9.3

type Impact struct {
	Caller *Node   `json:"caller"`
	Calls  []*Node `json:"calls"`
}

type Import

type Import struct {
	FromFile string `json:"from"`
	Path     string `json:"path"`
	ToModule string `json:"to,omitempty"`
}

type Kind

type Kind string
const (
	KindFunction    Kind = "function"
	KindMethod      Kind = "method"
	KindClass       Kind = "class"
	KindInterface   Kind = "interface"
	KindType        Kind = "type"
	KindConstructor Kind = "constructor"
	KindModule      Kind = "module"
	KindConstant    Kind = "constant"
	KindVariable    Kind = "variable"
)

type LangStat

type LangStat struct {
	Lang  string `json:"lang"`
	Files int    `json:"files"`
	Nodes int    `json:"nodes"`
}

type ModuleDep

type ModuleDep struct {
	Module     string `json:"module"`
	DependsOn  int    `json:"depends_on"`
	DependedBy int    `json:"depended_by"`
}

type ModuleStat

type ModuleStat struct {
	Path  string `json:"path"`
	Files int    `json:"files"`
	Nodes int    `json:"nodes"`
}

type Node

type Node struct {
	ID        string `json:"id"`
	Kind      Kind   `json:"kind"`
	Name      string `json:"name"`
	File      string `json:"file"`
	StartLine int    `json:"start_line"`
	EndLine   int    `json:"end_line"`
	Lang      string `json:"lang"`
}

type Option

type Option func(*Engine)

func WithResolver

func WithResolver(r CallResolver) Option

type Path

type Path struct {
	Nodes []*Node
	Via   []Provenance
}

type Provenance

type Provenance string
const (
	ViaName      Provenance = "name"
	ViaLSP       Provenance = "lsp"
	ViaAmbiguous Provenance = "ambiguous"
)

type RawContentHit added in v0.12.7

type RawContentHit struct {
	File    string `json:"file"`
	Line    int    `json:"line"`
	Content string `json:"content"`
}

type SearchOpts

type SearchOpts struct {
	Query  string
	Kind   Kind
	File   string
	Limit  int
	Offset int
}

type SearchResult added in v0.12.7

type SearchResult struct {
	Nodes   []*Node `json:"nodes"`
	Total   int     `json:"total"`
	Offset  int     `json:"offset"`
	HasMore bool    `json:"has_more"`
}

type Similar

type Similar struct {
	Node  *Node   `json:"node"`
	Score float64 `json:"score"`
}

type SimilarResult

type SimilarResult struct {
	Target  *Node     `json:"target"`
	Matches []Similar `json:"matches"`
	Others  []*Node   `json:"others,omitempty"`
}

type Snippet

type Snippet struct {
	Node   *Node
	Code   string
	Others []*Node
}

type Status

type Status struct {
	Indexed   bool
	IndexedAt time.Time
	Files     int
	Nodes     int
	Edges     int
	Skipped   []CoverageIssue
}

type TestsResult

type TestsResult struct {
	Symbol   *Node   `json:"symbol"`
	TestedBy []*Node `json:"tested_by"`
	Covers   []*Node `json:"covers"`
	Others   []*Node `json:"others,omitempty"`
}

type TraceResult

type TraceResult struct {
	Roots []*Node
	Paths []Path
}

Jump to

Keyboard shortcuts

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