MCPcopy Create free account
hub / github.com/diillson/chatcli / resolveGraphData

Function resolveGraphData

cli/plugins/builtin_graphview.go:428–462  ·  view source on GitHub ↗

resolveGraphData produces the renderable data for the chosen source.

(cfg graphViewArgs)

Source from the content-addressed store, hash-verified

426
427// resolveGraphData produces the renderable data for the chosen source.
428func resolveGraphData(cfg graphViewArgs) (GraphData, error) {
429 switch cfg.Source {
430 case "knowledge", "conversation":
431 prov := currentGraphSourceProvider()
432 if prov == nil {
433 return GraphData{}, fmt.Errorf("source %q is unavailable here; pass nodes/edges with source=json instead", cfg.Source)
434 }
435 var (
436 data GraphData
437 err error
438 )
439 if cfg.Source == "knowledge" {
440 data, err = prov.KnowledgeGraph()
441 } else {
442 data, err = prov.ConversationGraph()
443 }
444 if err != nil {
445 return GraphData{}, err
446 }
447 applyGraphMeta(&data, cfg)
448 return sanitizeGraphData(data), nil
449 default: // json
450 data := GraphData{Nodes: cfg.Nodes, Edges: cfg.Edges}
451 if cfg.File != "" {
452 fileData, err := readGraphDataFile(cfg.File)
453 if err != nil {
454 return GraphData{}, err
455 }
456 data.Nodes = append(data.Nodes, fileData.Nodes...)
457 data.Edges = append(data.Edges, fileData.Edges...)
458 }
459 applyGraphMeta(&data, cfg)
460 return sanitizeGraphData(data), nil
461 }
462}
463
464func applyGraphMeta(data *GraphData, cfg graphViewArgs) {
465 if cfg.Title != "" {

Calls 7

applyGraphMetaFunction · 0.85
sanitizeGraphDataFunction · 0.85
readGraphDataFileFunction · 0.85
ErrorfMethod · 0.80
KnowledgeGraphMethod · 0.65
ConversationGraphMethod · 0.65