output

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package output provides formatters for CLI output. TOON format is the default for agent-friendly, token-efficient output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompactID

func CompactID(id string) string

CompactID shortens verbose IDs for compact mode.

func FormatSize

func FormatSize(bytes int64) string

FormatSize formats a byte size as a human-readable string.

func GenerateSummaryMarkdown

func GenerateSummaryMarkdown(nodes []*graph.Node, edges []*graph.Edge, opts SummaryOptions) string

GenerateSummaryMarkdown generates a markdown summary of the graph.

func GenerateTOON

func GenerateTOON(nodes []*graph.Node, edges []*graph.Edge, opts TOONOptions) string

GenerateTOON generates TOON format output from nodes and edges.

func WriteTOONGzipped

func WriteTOONGzipped(path string, content string) error

WriteTOONGzipped writes TOON content to a gzip-compressed file.

Types

type Edge

type Edge struct {
	From            string  `toon:"from"`
	To              string  `toon:"to"`
	Confidence      string  `toon:"confidence,omitempty"`
	ConfidenceScore float64 `toon:"confidence_score,omitempty"`
}

Edge represents an edge in TOON export.

type Format

type Format string

Format represents an output format.

const (
	FormatTOON Format = "toon"
	FormatJSON Format = "json"
	FormatYAML Format = "yaml"
)

type Formatter

type Formatter interface {
	Format(v any) ([]byte, error)
}

Formatter formats data for output.

func NewFormatter

func NewFormatter(format Format) (Formatter, error)

NewFormatter creates a formatter for the specified format.

type GraphExport

type GraphExport struct {
	Stats Stats             `toon:"stats"`
	Nodes map[string][]Node `toon:"nodes"`
	Edges map[string][]Edge `toon:"edges"`
}

GraphExport represents the TOON export structure for a graph.

type JSONFormatter

type JSONFormatter struct {
	Indent bool
}

JSONFormatter outputs in JSON format.

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(v any) ([]byte, error)

Format formats data as JSON.

type Node

type Node struct {
	ID      string `toon:"id"`
	Label   string `toon:"label,omitempty"`
	Package string `toon:"pkg,omitempty"`
	File    string `toon:"file,omitempty"`
}

Node represents a node in TOON export.

type Stats

type Stats struct {
	Nodes int `toon:"nodes"`
	Edges int `toon:"edges"`
}

Stats contains graph statistics.

type SummaryOptions

type SummaryOptions struct {
	// TopN is the number of top nodes to show per category.
	TopN int
}

SummaryOptions configures summary markdown generation.

type TOONFormatter

type TOONFormatter struct{}

TOONFormatter outputs in TOON format (token-efficient for LLMs).

func (*TOONFormatter) Format

func (f *TOONFormatter) Format(v any) ([]byte, error)

Format formats data as TOON. TODO: Use github.com/toon-format/toon-go when available. For now, we implement a simple TOON-like format.

type TOONOptions

type TOONOptions struct {
	// NoExtra excludes source locations and extra metadata.
	NoExtra bool

	// Compact uses shorter IDs and implies NoExtra.
	Compact bool
}

TOONOptions configures TOON output generation.

type YAMLFormatter

type YAMLFormatter struct{}

YAMLFormatter outputs in YAML format.

func (*YAMLFormatter) Format

func (f *YAMLFormatter) Format(v any) ([]byte, error)

Format formats data as YAML.

Jump to

Keyboard shortcuts

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