Documentation
¶
Overview ¶
Package output defines the shared CLI response contract for agent-friendly output modes.
Index ¶
- Constants
- func ExitCode(err error) int
- func OK(cmd *cobra.Command, data any, summary string, breadcrumbs ...Breadcrumb) error
- func RegisterPersistentFlags(cmd *cobra.Command)
- func RenderError(cmd *cobra.Command, err error) error
- func SuppressesHumanOutput(opts Options) bool
- func UsesStructuredOutput(opts Options) bool
- type Breadcrumb
- type CLIError
- type Envelope
- type ErrorEnvelope
- type Mode
- type Options
Constants ¶
const ( CodeError = "error" CodeUsage = "usage_error" CodeOutputMode = "invalid_output_mode" CodeProjectNotFound = "project_not_found" CodeMissingTool = "missing_tool" CodeInvalidExtension = "invalid_extension" CodeInvalidInertiaAdapter = "invalid_inertia_adapter" CodeUnsafeAction = "unsafe_action_requires_confirmation" CodeGenerationFailed = "generation_failed" CodeExternalCommandFailed = "external_command_failed" CodeConfigError = "config_error" CodeAmbiguousInput = "ambiguous_input" ExitUsage = 1 ExitProject = 2 ExitDependency = 3 ExitUnsafe = 4 ExitGeneration = 5 ExitExternal = 6 ExitConfig = 7 ExitAmbiguous = 8 )
Variables ¶
This section is empty.
Functions ¶
func RegisterPersistentFlags ¶
RegisterPersistentFlags adds the shared agent-friendly output flags.
func RenderError ¶
RenderError renders a failed response using the selected output mode.
func SuppressesHumanOutput ¶
SuppressesHumanOutput reports whether command progress from lower-level routines should be hidden before rendering the final response.
func UsesStructuredOutput ¶
UsesStructuredOutput reports whether a command should render through the shared output contract instead of human prose.
Types ¶
type Breadcrumb ¶
type Breadcrumb struct {
Command string `json:"cmd"`
Description string `json:"description,omitempty"`
}
Breadcrumb is a follow-up action an agent or human can take.
type CLIError ¶
CLIError is a typed command error with a stable machine-readable code.
type Envelope ¶
type Envelope struct {
OK bool `json:"ok"`
Data any `json:"data,omitempty"`
Summary string `json:"summary,omitempty"`
Breadcrumbs []Breadcrumb `json:"breadcrumbs,omitempty"`
}
Envelope wraps successful structured command output.
type ErrorEnvelope ¶
type ErrorEnvelope struct {
OK bool `json:"ok"`
Code string `json:"code"`
Error string `json:"error"`
Hint string `json:"hint,omitempty"`
ExitCode int `json:"exit_code,omitempty"`
}
ErrorEnvelope wraps failed structured command output.
func Fail ¶
func Fail(err error) ErrorEnvelope
Fail converts any error into a structured error envelope.