Documentation
¶
Overview ¶
Package generate builds a seed Contexo knowledge base from a codebase by running the external Graphify CLI, parsing its graph.json, and mapping the code graph into migrate Candidates the agent then distills into pages.
Index ¶
- func BuildCandidates(g *Graph, projectRoot, graphifyOutDir, cacheDir string, caps Caps) ([]migrate.Candidate, error)
- func CacheDir(contexoDir string) string
- func DefaultRunner(projectRoot, cacheDir, backend string) (string, error)
- func Discover(projectRoot, contexoDir, backend string, runner Runner) ([]migrate.Candidate, string, error)
- func GraphifyInstalled() bool
- func InstallGraphify() (method string, err error)
- type Caps
- type Graph
- type Link
- type Node
- type Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCandidates ¶
func BuildCandidates(g *Graph, projectRoot, graphifyOutDir, cacheDir string, caps Caps) ([]migrate.Candidate, error)
BuildCandidates maps a parsed graph into migrate Candidates, materializing a markdown slice file per community/god-node under <cacheDir>/slices/. Order: overview, then communities (largest first), then god nodes. If g is nil it degrades to just the GRAPH_REPORT.md overview candidate.
func CacheDir ¶
CacheDir is where generate keeps Graphify artifacts + slices (a dot-dir, so migrate's Store.Walk exclusion keeps it out of pushes).
func DefaultRunner ¶
DefaultRunner shells out to the user-installed `graphify` CLI (keyless code extraction), then relocates <projectRoot>/graphify-out into the cache so the repo root is left clean.
func Discover ¶
func Discover(projectRoot, contexoDir, backend string, runner Runner) ([]migrate.Candidate, string, error)
Discover runs Graphify (via runner) and maps its output into candidates. A missing/unparseable graph.json degrades to the report-only candidate.
func GraphifyInstalled ¶
func GraphifyInstalled() bool
GraphifyInstalled reports whether the `graphify` CLI is on PATH.
func InstallGraphify ¶
InstallGraphify installs the `graphifyy` package with the first available installer (uv → pipx → pip → …) and returns which one it used. The package name is fixed and passed as an arg slice (no shell, no injection). It returns an error listing the manual commands when no installer is on PATH.
Types ¶
type Caps ¶
type Caps struct{ Communities, GodNodes int }
Caps bound how many communities / god nodes become candidates, so a large codebase doesn't explode into hundreds of pages.
func DefaultCaps ¶
func DefaultCaps() Caps
type Graph ¶
Graph is Graphify's networkx node-link output (only the parts we use).
func ParseGraph ¶
ParseGraph decodes a graph.json. Errors on malformed JSON or an empty node set (callers degrade to the report-only path on error).
func (*Graph) Communities ¶
Communities groups nodes by their community id.
func (*Graph) GodNodes ¶
GodNodes returns the topM most-connected SYMBOL nodes (files excluded), by degree descending, id ascending as a deterministic tiebreak.
func (*Graph) NeighborsOf ¶
NeighborsOf returns every link touching id (as source or target).
type Link ¶
type Link struct {
Source string `json:"source"`
Target string `json:"target"`
Relation string `json:"relation"`
Confidence string `json:"confidence"`
SourceFile string `json:"source_file"`
SourceLoc string `json:"source_location"`
Weight float64 `json:"weight"`
}
Link is one graph.json edge.
type Node ¶
type Node struct {
ID string `json:"id"`
Label string `json:"label"`
Community int `json:"community"`
CommunityName string `json:"community_name"`
SourceFile string `json:"source_file"`
SourceLoc string `json:"source_location"`
FileType string `json:"file_type"`
NormLabel string `json:"norm_label"`
}
Node is one graph.json node (a file or a code symbol).