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
- Variables
- func AddAgentFlag(cmd *cobra.Command)
- func AddAutoCommitFlags(cmd *cobra.Command)
- func ApplyAgentOverride(cmd *cobra.Command, cfg *config.Configuration) (bool, error)
- func ApplyAutoCommitOverride(cmd *cobra.Command, cfg *config.Configuration) bool
- func ApplyOutputStyle(cmd *cobra.Command, orch *workflow.WorkflowOrchestrator) config.OutputStyle
- func CenterText(text string, width int) string
- func ExitCode(err error) int
- func GetTerminalWidth() int
- func NewExitError(code int) error
- func PrintBanner(out io.Writer)
- func PrintBannerCompact(out io.Writer)
- func PrintSpecInfo(metadata SpecMetadata)
- func ResolveAgent(cmd *cobra.Command, cfg *config.Configuration) (cliagent.Agent, error)
- func ShowSecurityNotice(out io.Writer, cfg *config.Configuration, agentName string)
- type Colors
- type SpecMetadata
Constants ¶
const ( BoxTopLeft = "╭" BoxTopRight = "╮" BoxBottomLeft = "╰" BoxBottomRight = "╯" BoxHorizontal = "─" BoxVertical = "│" )
Box drawing characters
const ( GroupGettingStarted = "getting-started" GroupWorkflows = "workflows" GroupCoreStages = "core-stages" GroupOptionalStages = "optional-stages" GroupConfiguration = "configuration" GroupInternal = "internal" )
Command group IDs for organizing help output
const ( ExitSuccess = 0 ExitValidationFailed = 1 ExitRetryLimitReached = 2 ExitInvalidArguments = 3 ExitMissingDependency = 4 ExitTimeout = 5 )
Exit codes for CLI commands
const AgentFlagName = "agent"
AgentFlagName is the flag name for agent override.
const AutoCommitFlagName = "auto-commit"
AutoCommitFlagName is the flag name for enabling auto-commit.
const LogoDisplayWidth = 33
LogoDisplayWidth is the visual width of the logo (for centering).
const NoAutoCommitFlagName = "no-auto-commit"
NoAutoCommitFlagName is the flag name for disabling auto-commit.
const Tagline = "Spec-Driven Development Automation"
Tagline is the project tagline.
Variables ¶
var Logo = []string{
"▄▀█ █ █ ▀█▀ █▀█ █▀ █▀█ █▀▀ █▀▀",
"█▀█ █▄█ █ █▄█ ▄█ █▀▀ ██▄ █▄▄",
}
Logo is the ASCII art logo for autospec - minimal block style. Both lines are exactly 33 display characters wide.
Functions ¶
func AddAgentFlag ¶
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 ¶
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 ¶
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 ¶
CenterText centers text within a given width.
func GetTerminalWidth ¶
func GetTerminalWidth() int
GetTerminalWidth returns the terminal width, defaulting to 80 if unavailable.
func NewExitError ¶
NewExitError creates a new exit error with the given code.
func PrintBanner ¶
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 ¶
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 ¶
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.
type SpecMetadata ¶
type SpecMetadata interface {
FormatInfo() string
}
SpecMetadata is an interface for spec metadata that can format info.