output

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package output defines the OutputFormatter interface for writing scan results in various formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterFormatter

func RegisterFormatter(f Formatter)

RegisterFormatter adds a formatter to the global registry.

func SignalID added in v0.9.0

func SignalID(sig signal.RawSignal, prefix string) string

SignalID produces a deterministic ID from signal content. It hashes Source + Kind + FilePath + Line + Title using SHA-256, truncates to 8 hex characters, and prepends the given prefix.

Types

type BeadsFormatter

type BeadsFormatter struct {
	// contains filtered or unexported fields
}

BeadsFormatter writes signals as Beads-compatible JSONL.

func NewBeadsFormatter

func NewBeadsFormatter() *BeadsFormatter

NewBeadsFormatter returns a new BeadsFormatter.

func (*BeadsFormatter) Format

func (b *BeadsFormatter) Format(signals []signal.RawSignal, w io.Writer) error

Format writes each signal as a single-line JSON object to w. Each line is valid JSON parseable by `bd import`.

func (*BeadsFormatter) Name

func (b *BeadsFormatter) Name() string

Name returns the format name.

func (*BeadsFormatter) SetConventions added in v0.4.0

func (b *BeadsFormatter) SetConventions(c *beads.Conventions)

SetConventions configures the formatter to adopt existing beads conventions. Passing nil resets to default behavior.

type DirectoryFormatter added in v1.0.0

type DirectoryFormatter interface {
	Formatter
	FormatDir(signals []signal.RawSignal, dir string) error
}

DirectoryFormatter extends Formatter for formats that produce a directory of files (e.g., index.html + assets/) instead of a single stream.

type Formatter

type Formatter interface {
	// Name returns the format name (e.g., "beads", "json", "markdown").
	Name() string

	// Format writes the signals to w.
	Format(signals []signal.RawSignal, w io.Writer) error
}

Formatter writes a slice of raw signals to the given writer in a specific format.

func GetFormatter

func GetFormatter(name string) (Formatter, error)

GetFormatter returns the formatter with the given name, or an error if not found.

type HTMLDirFormatter added in v1.0.0

type HTMLDirFormatter struct {
	// contains filtered or unexported fields
}

HTMLDirFormatter writes signals as an HTML dashboard with external CSS and JS in a directory structure: index.html + assets/dashboard.{css,js}.

func NewHTMLDirFormatter added in v1.0.0

func NewHTMLDirFormatter() *HTMLDirFormatter

NewHTMLDirFormatter returns a new HTMLDirFormatter.

func (*HTMLDirFormatter) Format added in v1.0.0

func (h *HTMLDirFormatter) Format(_ []signal.RawSignal, _ io.Writer) error

Format returns an error directing users to use --output (-o) with html-dir.

func (*HTMLDirFormatter) FormatDir added in v1.0.0

func (h *HTMLDirFormatter) FormatDir(signals []signal.RawSignal, dir string) error

FormatDir writes the dashboard to dir as index.html + assets/.

func (*HTMLDirFormatter) Name added in v1.0.0

func (h *HTMLDirFormatter) Name() string

Name returns the format name.

type HTMLFormatter added in v1.0.0

type HTMLFormatter struct {
	// contains filtered or unexported fields
}

HTMLFormatter writes signals as a self-contained HTML dashboard.

func NewHTMLFormatter added in v1.0.0

func NewHTMLFormatter() *HTMLFormatter

NewHTMLFormatter returns a new HTMLFormatter.

func (*HTMLFormatter) Format added in v1.0.0

func (h *HTMLFormatter) Format(signals []signal.RawSignal, w io.Writer) error

Format writes all signals as a self-contained HTML dashboard to w.

func (*HTMLFormatter) Name added in v1.0.0

func (h *HTMLFormatter) Name() string

Name returns the format name.

type JSONEnvelope

type JSONEnvelope struct {
	Signals  []signal.RawSignal `json:"signals"`
	Metadata JSONMetadata       `json:"metadata"`
}

JSONEnvelope wraps signals with metadata for the JSON output format.

type JSONFormatter

type JSONFormatter struct {
	// Compact controls whether output is compact (single line) or pretty-printed.
	// When false (default), output is indented with two spaces.
	Compact bool
	// contains filtered or unexported fields
}

JSONFormatter writes signals as a JSON object with metadata envelope.

func NewJSONFormatter

func NewJSONFormatter() *JSONFormatter

NewJSONFormatter returns a new JSONFormatter with default settings.

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(signals []signal.RawSignal, w io.Writer) error

Format writes all signals as a JSON document with a metadata envelope to w. If Compact is false and w is a TTY (an *os.File connected to a terminal), or Compact is explicitly false, output is pretty-printed. If Compact is true, output is a single line.

func (*JSONFormatter) Name

func (f *JSONFormatter) Name() string

Name returns the format name.

type JSONMetadata

type JSONMetadata struct {
	TotalCount  int      `json:"total_count"`
	Collectors  []string `json:"collectors"`
	GeneratedAt string   `json:"generated_at"`
}

JSONMetadata contains information about the scan that produced these signals.

type MarkdownFormatter

type MarkdownFormatter struct{}

MarkdownFormatter writes signals as a human-readable Markdown summary.

func NewMarkdownFormatter

func NewMarkdownFormatter() *MarkdownFormatter

NewMarkdownFormatter returns a new MarkdownFormatter.

func (*MarkdownFormatter) Format

func (m *MarkdownFormatter) Format(signals []signal.RawSignal, w io.Writer) error

Format writes all signals as a grouped Markdown document to w.

When signals span multiple workspaces, output is grouped by workspace first, then by collector within each workspace. For single-workspace or non-monorepo signals, the output is unchanged (grouped by collector only).

func (*MarkdownFormatter) Name

func (m *MarkdownFormatter) Name() string

Name returns the format name.

type TasksEnvelope added in v0.4.0

type TasksEnvelope struct {
	Tasks    []taskRecord `json:"tasks"`
	Metadata JSONMetadata `json:"metadata"`
}

TasksEnvelope wraps tasks with metadata for the tasks output format.

type TasksFormatter added in v0.4.0

type TasksFormatter struct {
	// Compact controls whether output is compact or pretty-printed.
	Compact bool
	// contains filtered or unexported fields
}

TasksFormatter writes signals as Claude Code TaskCreate-compatible JSON.

func NewTasksFormatter added in v0.4.0

func NewTasksFormatter() *TasksFormatter

NewTasksFormatter returns a new TasksFormatter with default settings.

func (*TasksFormatter) Format added in v0.4.0

func (f *TasksFormatter) Format(signals []signal.RawSignal, w io.Writer) error

Format writes all signals as a tasks JSON document to w.

func (*TasksFormatter) Name added in v0.4.0

func (f *TasksFormatter) Name() string

Name returns the format name.

Jump to

Keyboard shortcuts

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