Help us shape the future of Go! Take the 2026 Go Developer Survey

rendering

package
v1.55.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package rendering implements the centralized UI rendering engine for plugin output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine renders output blocks sent by plugins over the CoreCLIHelper RPCs.

All rendering goes to the writers the host configured, never to the plugin's own stdio. Rendering is serialized so that blocks appear in the order the plugin sent them even when a plugin sends from multiple goroutines.

func NewEngine

func NewEngine(format Format) *Engine

NewEngine creates an Engine that writes to the process's stdout and stderr.

func NewEngineWithWriters

func NewEngineWithWriters(format Format, stdout, stderr io.Writer) *Engine

NewEngineWithWriters creates an Engine that writes to the given streams.

func (*Engine) HandleCommandOutput

func (e *Engine) HandleCommandOutput(req *proto.SendCommandOutputRequest)

HandleCommandOutput renders output blocks sent by a plugin.

This is the only RPC that carries output, so a request may hold incremental chatter, the command's final result, or both. req.Final marks the last one.

func (*Engine) HandlePrompt

func (e *Engine) HandlePrompt(req *proto.PromptRequest) *proto.PromptResponse

HandlePrompt asks the user a question and returns their answer.

Milestone 1 keeps this deliberately minimal: prompts still render as plain text and resolve to the caller's default. Interactive prompting is a separate milestone.

type EnvelopeBlock

type EnvelopeBlock struct {
	Type    string          `json:"type"`
	Payload json.RawMessage `json:"payload"`
}

EnvelopeBlock represents a single output block in the JSON envelope.

type Format

type Format string

Format selects how the engine renders plugin output.

const (
	// FormatText renders human-readable output.
	FormatText Format = "text"
	// FormatJSON renders a single JSON envelope for the command's final output.
	FormatJSON Format = "json"
)

type JSONEnvelope

type JSONEnvelope struct {
	Command string          `json:"command"`
	Data    []EnvelopeBlock `json:"data"`
}

JSONEnvelope is the standard output format for --format=json. Only success output goes here (stdout). Errors go to stderr + non-zero exit.

Jump to

Keyboard shortcuts

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