contextgraph

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package contextgraph builds a directed knowledge graph that links tasks, their dependency edges, associated file artifacts, KB entries, task annotations, and git commits into a single queryable structure.

Supported output formats:

  • json — {nodes:[{id,type,label}], edges:[{from,to,rel}]}
  • dot — Graphviz DOT digraph (pipe through dot -Tpng etc.)
  • mermaid — Mermaid flowchart TD wrapped in a fenced code block

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderDOT

func RenderDOT(g *Graph) string

RenderDOT produces a Graphviz DOT digraph.

Node shapes and fill colours by type:

  • task → box, colour by status (green/yellow/red/grey)
  • artifact → note shape, light blue
  • kb → ellipse, lavender
  • annotation → plaintext box, light yellow
  • commit → hexagon, light orange

func RenderJSON

func RenderJSON(g *Graph) (string, error)

RenderJSON serialises the graph as indented JSON.

func RenderMermaid

func RenderMermaid(g *Graph) string

RenderMermaid produces a Mermaid flowchart (TD direction).

Types

type Edge

type Edge struct {
	From string  `json:"from"`
	To   string  `json:"to"`
	Rel  EdgeRel `json:"rel"`
}

Edge is a directed edge in the context graph.

type EdgeRel

type EdgeRel string

EdgeRel names the semantic relationship between two nodes.

const (
	RelDependsOn EdgeRel = "depends_on" // task → task
	RelProduced  EdgeRel = "produced"   // task → artifact
	RelAnnotated EdgeRel = "annotated"  // task → annotation
	RelLinkedKB  EdgeRel = "linked_kb"  // task → kb
	RelCommit    EdgeRel = "commit"     // commit → task
)

type Graph

type Graph struct {
	Nodes []*Node `json:"nodes"`
	Edges []*Edge `json:"edges"`
}

Graph is the full context graph.

func Collect

func Collect(workDir string) (*Graph, error)

Collect builds the context graph from all available project data in workDir. Non-fatal sources (artifacts, KB, trace) are silently skipped if unavailable.

type Node

type Node struct {
	ID    string   `json:"id"`
	Type  NodeType `json:"type"`
	Label string   `json:"label"`
	// Extra is format-specific metadata (not included in JSON output but used for rendering).
	Status string `json:"status,omitempty"` // for task nodes: pending/in_progress/done/failed/skipped
}

Node is a single vertex in the context graph.

type NodeType

type NodeType string

NodeType identifies what kind of entity a graph node represents.

const (
	NodeTask       NodeType = "task"
	NodeArtifact   NodeType = "artifact"
	NodeKB         NodeType = "kb"
	NodeAnnotation NodeType = "annotation"
	NodeCommit     NodeType = "commit"
)

Jump to

Keyboard shortcuts

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