shared

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package shared provides constants and types used across CLI subpackages.

Package shared provides constants and types used across CLI subpackages.

Package shared provides constants and types used across CLI subpackages.

Package shared provides constants and types used across CLI subpackages. This package has no dependencies on other CLI packages to avoid circular imports.

Package shared provides constants and types used across CLI subpackages.

Index

Constants

View Source
const (
	BoxTopLeft     = "╭"
	BoxTopRight    = "╮"
	BoxBottomLeft  = "╰"
	BoxBottomRight = "╯"
	BoxHorizontal  = "─"
	BoxVertical    = "│"
)

Box drawing characters

View Source
const (
	GroupGettingStarted = "getting-started"
	GroupWorkflows      = "workflows"
	GroupCoreStages     = "core-stages"
	GroupOptionalStages = "optional-stages"
	GroupConfiguration  = "configuration"
	GroupInternal       = "internal"
)

Command group IDs for organizing help output

View Source
const (
	ExitSuccess           = 0
	ExitValidationFailed  = 1
	ExitRetryLimitReached = 2
	ExitInvalidArguments  = 3
	ExitMissingDependency = 4
	ExitTimeout           = 5
)

Exit codes for CLI commands

View Source
const AgentFlagName = "agent"

AgentFlagName is the flag name for agent override.

View Source
const AutoCommitFlagName = "auto-commit"

AutoCommitFlagName is the flag name for enabling auto-commit.

View Source
const LogoDisplayWidth = 33

LogoDisplayWidth is the visual width of the logo (for centering).

View Source
const NoAutoCommitFlagName = "no-auto-commit"

NoAutoCommitFlagName is the flag name for disabling auto-commit.

View Source
const Tagline = "Spec-Driven Development Automation"

Tagline is the project tagline.

Variables

View Source
	"▄▀█ █ █ ▀█▀ █▀█ █▀ █▀█ █▀▀ █▀▀",
	"█▀█ █▄█  █  █▄█ ▄█ █▀▀ ██▄ █▄▄",
}

Logo is the ASCII art logo for autospec - minimal block style. Both lines are exactly 33 display characters wide.

Functions

func AddAgentFlag

func AddAgentFlag(cmd *cobra.Command)

AddAgentFlag adds the --agent flag to a command. The flag allows users to override the configured agent for a single execution. In production builds (multi-agent disabled), this is a no-op.

func AddAutoCommitFlags

func AddAutoCommitFlags(cmd *cobra.Command)

AddAutoCommitFlags adds --auto-commit and --no-auto-commit flags to a command. These flags allow users to override the configured auto_commit behavior for a single execution. The flags are marked mutually exclusive.

func ApplyAgentOverride

func ApplyAgentOverride(cmd *cobra.Command, cfg *config.Configuration) (bool, error)

ApplyAgentOverride updates the configuration with an agent override from CLI flag. This modifies the config's AgentPreset field so that workflow orchestrator picks it up. Returns true if an override was applied. In production builds (multi-agent disabled), this is a no-op.

func ApplyAutoCommitOverride

func ApplyAutoCommitOverride(cmd *cobra.Command, cfg *config.Configuration) bool

ApplyAutoCommitOverride updates the configuration's AutoCommit field based on CLI flags. Returns true if an override was applied. Priority: --auto-commit or --no-auto-commit flag > config file > default (true). Also updates AutoCommitSource to SourceFlag when a flag is used.

func ApplyOutputStyle

func ApplyOutputStyle(cmd *cobra.Command, orch *workflow.WorkflowOrchestrator) config.OutputStyle

ApplyOutputStyle reads the --output-style flag from the command and applies it to the workflow orchestrator. If the flag is set, it takes precedence over the config file value (cclean.style). Returns the effective OutputStyle.

func CenterText

func CenterText(text string, width int) string

CenterText centers text within a given width.

func ExitCode

func ExitCode(err error) int

ExitCode returns the exit code from an error.

func GetTerminalWidth

func GetTerminalWidth() int

GetTerminalWidth returns the terminal width, defaulting to 80 if unavailable.

func NewExitError

func NewExitError(code int) error

NewExitError creates a new exit error with the given code.

func PrintBanner

func PrintBanner(out io.Writer)

PrintBanner prints the colored ASCII logo and tagline. Uses cyan for the logo and dim for the tagline. Logo and tagline are left-aligned for consistency with command output.

func PrintBannerCompact

func PrintBannerCompact(out io.Writer)

PrintBannerCompact prints just the logo without tagline (for init command). Logo is left-aligned for consistency with command output.

func PrintSpecInfo

func PrintSpecInfo(metadata SpecMetadata)

PrintSpecInfo prints the spec metadata if available.

func ResolveAgent

func ResolveAgent(cmd *cobra.Command, cfg *config.Configuration) (cliagent.Agent, error)

ResolveAgent resolves the agent to use based on CLI flag and config. Priority: CLI flag > config (agent_preset/custom_agent_cmd) > legacy fields > default (claude). In production builds (multi-agent disabled), always returns Claude.

func ShowSecurityNotice

func ShowSecurityNotice(out io.Writer, cfg *config.Configuration, agentName string)

ShowSecurityNotice displays the security notice if not already shown. This is a convenience wrapper around workflow.ShowSecurityNoticeOnce. Call this after resolving the agent but before starting any workflow execution.

The notice is only shown for Claude since it relates to --dangerously-skip-permissions. For other agents (opencode, gemini, etc.), the notice is skipped.

Example usage in a command:

cfg, err := config.Load(configPath)
if err != nil { return err }
agent, err := shared.ResolveAgent(cmd, cfg)
if err != nil { return err }
shared.ShowSecurityNotice(cmd.OutOrStdout(), cfg, agent.Name())
// ... continue with workflow execution

Types

type Colors

type Colors struct {
	Cyan    func(a ...interface{}) string
	Green   func(a ...interface{}) string
	Yellow  func(a ...interface{}) string
	Red     func(a ...interface{}) string
	Dim     func(a ...interface{}) string
	White   func(a ...interface{}) string
	Magenta func(a ...interface{}) string
}

Colors provides reusable color functions for CLI output.

func NewColors

func NewColors() *Colors

NewColors creates a new Colors instance with standard terminal colors.

type SpecMetadata

type SpecMetadata interface {
	FormatInfo() string
}

SpecMetadata is an interface for spec metadata that can format info.

Jump to

Keyboard shortcuts

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