query

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package query answers questions against a built graph.json without rebuilding: find nodes by name, explain a node and its neighbours, and find the shortest dependency path between two nodes. These back the CLI commands the Claude skill uses instead of grepping the source tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate added in v0.3.0

func Validate(path string) (issues []string, nodes, links int, err error)

Validate reads graph.json at path and reports structural problems: links that reference a missing node (dangling endpoints), duplicate node IDs, and nodes with an empty ID. It returns the issues (empty when the graph is sound) plus node and edge counts for a summary. Reading directly (rather than via Load) lets it catch duplicate IDs, which Load's id map would otherwise collapse.

Types

type AffectedResult added in v0.3.0

type AffectedResult struct {
	Changed  []Node
	Impacted []Node
}

AffectedResult separates the symbols defined in the changed files from the symbols transitively impacted by them.

func Affected added in v0.3.0

func Affected(g *Graph, changedFiles []string) AffectedResult

Affected returns the graph nodes defined in changedFiles ("changed") and every node that transitively depends on them ("impacted") — the blast radius of a change. Impact propagates backwards along dependency edges: a changed callee reaches its callers, a changed file reaches its importers.

type Explanation

type Explanation struct {
	Node      *Node
	Neighbors []Neighbor
}

Explanation is a node plus its grouped neighbours.

func Explain

func Explain(g *Graph, id string) (*Explanation, error)

Explain returns a node and its neighbours, labelled by relation and direction (-> outgoing, <- incoming). id may be a full node ID or a label substring with a unique match.

type Graph

type Graph struct {
	Nodes []Node `json:"nodes"`
	Links []Link `json:"links"`
	// contains filtered or unexported fields
}

Graph is a loaded graph.json.

func Load

func Load(path string) (*Graph, error)

Load reads and validates a graph.json at path. The path must resolve inside a graphify-out directory and stay under the size cap.

type Link struct {
	Source     string `json:"source"`
	Target     string `json:"target"`
	Relation   string `json:"relation"`
	Confidence string `json:"confidence"`
}

Link mirrors a graph.json edge.

type Match

type Match struct {
	ID, Label, Location string
}

Match is a node found by Query.

func Query

func Query(g *Graph, pattern string) ([]Match, error)

Query returns nodes whose id, label, or normalised label matches the given regular expression (case-insensitive). Results are sorted by label.

type Neighbor

type Neighbor struct {
	ID, Label, Relation, Direction, Location string
}

Neighbor is an adjacent node in a given direction.

type Node

type Node struct {
	ID             string `json:"id"`
	Label          string `json:"label"`
	FileType       string `json:"file_type"`
	SourceFile     string `json:"source_file"`
	SourceLocation string `json:"source_location"`
	Community      *int   `json:"community"`
	NormLabel      string `json:"norm_label"`
	ComputedName   string `json:"computed_name"`
}

Node mirrors a graph.json node.

func Path

func Path(g *Graph, from, to string) ([]Node, error)

Path returns the shortest path (by node labels/ids) between two nodes via BFS on the undirected graph, or an error if no path exists.

Jump to

Keyboard shortcuts

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