cli

package
v0.20.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 62 Imported by: 0

Documentation

Overview

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas. This file provides execution context resolution for worktree support.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Package cli provides the command-line interface for atlas.

Index

Constants

View Source
const (
	ModelSonnet = "sonnet"
	ModelOpus   = "opus"
	ModelHaiku  = "haiku"
)

Model constants for descriptive labels.

View Source
const (
	// ExitSuccess indicates successful execution.
	ExitSuccess = 0
	// ExitError indicates a general error.
	ExitError = 1
	// ExitInvalidInput indicates invalid user input.
	ExitInvalidInput = 2
)

Exit codes for the CLI.

View Source
const (
	// OutputText is the default human-readable output format.
	OutputText = "text"
	// OutputJSON is the machine-readable JSON output format.
	OutputJSON = "json"
)

Output format constants.

View Source
const (
	NotifyEventAwaitingApproval = "awaiting_approval"
	NotifyEventValidationFailed = "validation_failed"
	NotifyEventCIFailed         = "ci_failed"
	NotifyEventGitHubFailed     = "github_failed"
)

Notification event constants. These define the events that can trigger notifications.

View Source
const (
	DefaultSmartCommitTimeout       = 30 * time.Second
	DefaultSmartCommitMaxRetries    = 2
	DefaultSmartCommitBackoffFactor = 1.5
)

Default values for smart commit and PR description configuration.

View Source
const DefaultWatchInterval = 2 * time.Second

DefaultWatchInterval is the default refresh interval for watch mode.

View Source
const MinWatchInterval = 500 * time.Millisecond

MinWatchInterval is the minimum allowed refresh interval for watch mode. Prevents excessive CPU usage from too-frequent refreshes.

Variables

This section is empty.

Functions

func AddAbandonCommand

func AddAbandonCommand(root *cobra.Command)

AddAbandonCommand adds the abandon command to the root command.

func AddApproveCommand

func AddApproveCommand(root *cobra.Command)

AddApproveCommand adds the approve command to the root command.

func AddBacklogCommand added in v0.7.0

func AddBacklogCommand(root *cobra.Command)

AddBacklogCommand adds the backlog command group to the root command.

func AddCheckpointCommand added in v0.7.0

func AddCheckpointCommand(root *cobra.Command)

AddCheckpointCommand adds the checkpoint command to the root command.

func AddCleanupCommand added in v0.7.0

func AddCleanupCommand(root *cobra.Command)

AddCleanupCommand adds the cleanup command to the root command.

func AddCompletionCommand added in v0.5.0

func AddCompletionCommand(rootCmd *cobra.Command)

AddCompletionCommand adds the completion command with subcommands to the root command. This replaces Cobra's default completion command with a custom one that includes an "install" subcommand for easy setup.

func AddConfigCommand

func AddConfigCommand(rootCmd *cobra.Command)

AddConfigCommand adds the config command to the root command.

func AddConfigNotificationCommand

func AddConfigNotificationCommand(configCmd *cobra.Command)

AddConfigNotificationCommand adds the 'notifications' subcommand to the config command. This is called from config_ai.go where the config command is defined.

func AddConfigShowCommand

func AddConfigShowCommand(configCmd *cobra.Command)

AddConfigShowCommand adds the show subcommand to the config command.

func AddConfigValidationCommand

func AddConfigValidationCommand(configCmd *cobra.Command)

AddConfigValidationCommand adds the 'validation' subcommand to the config command. This is called from config_ai.go where the config command is defined.

func AddDaemonCommand added in v0.14.2

func AddDaemonCommand(root *cobra.Command)

AddDaemonCommand adds the daemon command group to the root command.

func AddFormatCommand

func AddFormatCommand(root *cobra.Command)

AddFormatCommand adds the format command to the root command.

func AddGlobalFlags

func AddGlobalFlags(cmd *cobra.Command, flags *GlobalFlags)

AddGlobalFlags adds global flags to a command. These flags are available to all subcommands via PersistentFlags.

func AddHookCommand added in v0.7.0

func AddHookCommand(root *cobra.Command)

AddHookCommand adds the hook command group to the root command.

func AddInitCommand

func AddInitCommand(rootCmd *cobra.Command)

AddInitCommand adds the init command to the root command.

func AddLintCommand

func AddLintCommand(root *cobra.Command)

AddLintCommand adds the lint command to the root command.

func AddRejectCommand

func AddRejectCommand(root *cobra.Command)

AddRejectCommand adds the reject command to the root command.

func AddResumeCommand

func AddResumeCommand(root *cobra.Command)

AddResumeCommand adds the resume command to the root command.

func AddStartCommand

func AddStartCommand(root *cobra.Command)

AddStartCommand adds the start command to the root command.

func AddStatusCommand

func AddStatusCommand(parent *cobra.Command)

AddStatusCommand adds the status command to the root command.

func AddTestCommand

func AddTestCommand(root *cobra.Command)

AddTestCommand adds the test command to the root command.

func AddUICommand added in v0.14.2

func AddUICommand(root *cobra.Command)

AddUICommand adds the ui command to the root command.

func AddUpgradeCommand

func AddUpgradeCommand(rootCmd *cobra.Command)

AddUpgradeCommand adds the upgrade command to the root command.

func AddValidateCommand

func AddValidateCommand(root *cobra.Command)

AddValidateCommand adds the validate command to the root command.

func AddWorkspaceCommand

func AddWorkspaceCommand(parent *cobra.Command)

AddWorkspaceCommand adds the workspace command tree to the root command.

func AllNotificationEvents

func AllNotificationEvents() []string

AllNotificationEvents returns all supported notification event types.

func BindGlobalFlags

func BindGlobalFlags(v *viper.Viper, cmd *cobra.Command) error

BindGlobalFlags binds global flags to Viper for configuration file and environment variable support. The ATLAS_ prefix is used for environment variables (e.g., ATLAS_OUTPUT, ATLAS_VERBOSE).

func CheckAPIKeyExists

func CheckAPIKeyExists(envVarName string) (exists bool, warning string)

CheckAPIKeyExists checks if the specified environment variable is set. Returns whether the key exists and a warning message if it doesn't.

func CloseLogFile

func CloseLogFile()

CloseLogFile closes the global log file writer if it was opened. This should be called during application shutdown for clean cleanup.

func CollectAIConfigInteractive

func CollectAIConfigInteractive(ctx context.Context, cfg *AIProviderConfig) error

CollectAIConfigInteractive runs the AI configuration form and returns the collected config. It validates all inputs and handles form errors.

func CollectNotificationConfigInteractive

func CollectNotificationConfigInteractive(ctx context.Context, cfg *NotificationProviderConfig) error

CollectNotificationConfigInteractive runs the notification configuration form and returns the collected config. It validates all inputs and handles form errors.

func CollectValidationConfigInteractive

func CollectValidationConfigInteractive(ctx context.Context, cfg *ValidationProviderConfig, toolResult *config.ToolDetectionResult) error

CollectValidationConfigInteractive runs the validation configuration form. It populates the config with defaults based on detected tools and runs the form.

func CreateStores added in v0.8.0

func CreateStores(baseDir string) (workspace.Store, task.Store, error)

CreateStores creates workspace and task stores with unified error handling. Returns workspace store, task store, and error. Uses repo-scoped storage when baseDir is empty.

func EmitBell

func EmitBell()

EmitBell writes the BEL character to stdout to trigger the terminal bell. This works on most terminals including iTerm2, Terminal.app, tmux, etc.

func EmitBellTo

func EmitBellTo(w io.Writer)

EmitBellTo writes the BEL character to the specified writer. This allows testing without actually emitting to stdout.

func Execute

func Execute(ctx context.Context, info BuildInfo) error

Execute runs the root command with the provided context and build info.

func ExitCodeForError

func ExitCodeForError(err error) int

ExitCodeForError returns the appropriate exit code for the given error. Returns ExitSuccess (0) for nil errors, ExitInvalidInput (2) for user input errors (invalid flags, bad arguments), and ExitError (1) for all other errors.

func HandleCommandError added in v0.8.0

func HandleCommandError(format string, w io.Writer, response any, err error) error

HandleCommandError handles errors with optional JSON output. If format is JSON, it encodes the response and returns ErrJSONErrorOutput. Otherwise, it returns the original error.

func InitLogger

func InitLogger(verbose, quiet bool) zerolog.Logger

InitLogger creates and configures a zerolog.Logger based on verbosity flags.

Log levels are set as follows:

  • verbose=true: Debug level (most detailed)
  • quiet=true: Warn level (errors and warnings only)
  • default: Info level (normal operation)

Output format is determined by the terminal:

  • TTY with colors enabled: Console writer with timestamps
  • Non-TTY or NO_COLOR set: JSON output to stderr

The logger also writes to ~/.atlas/logs/atlas.log with rotation enabled. If the log file cannot be created, the logger will continue with console-only output.

func InitLoggerWithTaskStore

func InitLoggerWithTaskStore(verbose, quiet bool, store TaskLogAppender) zerolog.Logger

InitLoggerWithTaskStore creates a logger that persists task-specific logs. Log entries with workspace_name and task_id fields are written to the task's log file. All logs continue to go to console and global log file as normal.

func InitLoggerWithWriter

func InitLoggerWithWriter(verbose, quiet bool, w io.Writer) zerolog.Logger

InitLoggerWithWriter creates and configures a zerolog.Logger with a custom writer. This is primarily intended for testing purposes.

func IsValidEnvVarName

func IsValidEnvVarName(name string) bool

IsValidEnvVarName checks if a string is a valid environment variable name. A valid name starts with a letter or underscore and contains only letters, digits, or underscores.

func IsValidOutputFormat

func IsValidOutputFormat(format string) bool

IsValidOutputFormat checks if the given format is a valid output format.

func LogFilePath added in v0.5.0

func LogFilePath() (string, error)

LogFilePath returns the path to the global CLI log file. This is useful for displaying the log location to users.

func Logger added in v0.5.0

func Logger() zerolog.Logger

Logger returns the initialized logger for use by subcommands.

IMPORTANT: This function MUST only be called after the root command's PersistentPreRunE has executed. Calling it before initialization will return a zero-value logger that discards all log output.

This function is safe for concurrent use.

Typical usage is within a subcommand's Run/RunE function:

RunE: func(cmd *cobra.Command, args []string) error {
    logger := cli.Logger()
    logger.Info().Msg("executing command")
    ...
}

func LoggerWithTaskStore added in v0.5.0

func LoggerWithTaskStore(store TaskLogAppender) zerolog.Logger

LoggerWithTaskStore returns a logger configured to persist task-specific logs. Log entries containing workspace_name and task_id fields will be written to the task's log file in addition to the console and global log.

This function is safe for concurrent use.

func NewAIConfigForm

func NewAIConfigForm(cfg *AIProviderConfig, maxTurnsStr *string) *huh.Form

NewAIConfigForm creates a Charm Huh form for AI configuration. The form collects model, API key env var, timeout, and max turns settings. IMPORTANT: maxTurnsStr must be passed from the caller so the value can be captured after form.Run() completes. The caller is responsible for parsing maxTurnsStr back to cfg.MaxTurns.

func NewNotificationConfigForm

func NewNotificationConfigForm(cfg *NotificationProviderConfig) *huh.Form

NewNotificationConfigForm creates a Charm Huh form for notification configuration. The form collects bell enable/disable and event selection settings.

func NewValidationConfigForm

func NewValidationConfigForm(cfg *ValidationProviderConfig) *huh.Form

NewValidationConfigForm creates a Charm Huh form for validation configuration. The form collects format, lint, test, pre-commit, and custom pre-PR commands.

func NotifyIfEnabled

func NotifyIfEnabled(event string, cfg *NotificationConfig)

NotifyIfEnabled emits a bell if the event should trigger a notification. This is a convenience function combining ShouldNotify and EmitBell.

func NotifyIfEnabledTo

func NotifyIfEnabledTo(w io.Writer, event string, cfg *NotificationConfig)

NotifyIfEnabledTo emits a bell to the specified writer if the event should trigger a notification. This allows testing without actually emitting to stdout.

func ParseMaxTurnsWithDefault

func ParseMaxTurnsWithDefault(s string, defaultVal int) int

ParseMaxTurnsWithDefault parses a string to int, returning a default on error.

func ParseMultilineInput

func ParseMultilineInput(input string) []string

ParseMultilineInput splits multiline input into a slice of strings. Each line is trimmed of whitespace and empty lines are filtered out.

func PopulateNotificationConfigDefaults

func PopulateNotificationConfigDefaults(cfg *NotificationProviderConfig)

PopulateNotificationConfigDefaults populates the config with default values.

func PopulateValidationConfigDefaults

func PopulateValidationConfigDefaults(cfg *ValidationProviderConfig, toolResult *config.ToolDetectionResult)

PopulateValidationConfigDefaults populates the config with suggested defaults based on detected tools. The defaults are set as multiline strings for display in the form.

func RunDaemonProcess added in v0.14.2

func RunDaemonProcess(ctx context.Context) error

RunDaemonProcess starts the daemon process in-process (blocking). Called when the binary is invoked with the --daemon flag.

func SelectWorkspaceTask added in v0.8.0

func SelectWorkspaceTask[T WorkspaceTaskSelector](prompt string, items []T) (int, error)

SelectWorkspaceTask presents a selection menu and returns the selected item's index. It uses generics to work with any type implementing WorkspaceTaskSelector.

func ShouldNotify

func ShouldNotify(event string, cfg *NotificationConfig) bool

ShouldNotify checks if a notification should be triggered for an event. Returns true if bell is enabled and the event is in the configured events list.

func ValidOutputFormats

func ValidOutputFormats() []string

ValidOutputFormats returns the list of valid output format values.

func ValidateAIConfig

func ValidateAIConfig(cfg *AIProviderConfig) error

ValidateAIConfig validates an AIProviderConfig and returns any validation errors.

func ValidateAllConfigCommands

func ValidateAllConfigCommands(cfg *ValidationProviderConfig) map[string][]string

ValidateAllConfigCommands validates all commands in the configuration. Returns a map of category to warnings for that category.

func ValidateCommand

func ValidateCommand(cmd string) (exists bool, warning string)

ValidateCommand checks if a command is executable. It returns whether the command exists in PATH and a warning message if not. The function only checks the base command (first word), ignoring arguments.

func ValidateCommands

func ValidateCommands(multilineInput string) []string

ValidateCommands checks all commands in a multiline string. Returns a slice of warnings for commands that are not found. Commands are not rejected - only warnings are returned.

func ValidateNotificationConfig

func ValidateNotificationConfig(_ *NotificationProviderConfig) error

ValidateNotificationConfig validates a NotificationProviderConfig. Returns an error if the configuration is invalid.

func ValidateTimeoutWithDefault

func ValidateTimeoutWithDefault(s, defaultVal string) string

ValidateTimeoutWithDefault validates and returns a timeout string. If the input is invalid, returns the default value.

func WithExecutionContext

func WithExecutionContext(ctx context.Context, ec *ExecutionContext) context.Context

WithExecutionContext returns a new context with the ExecutionContext attached.

Types

type AIConfig

type AIConfig struct {
	// Model is the default Claude model to use (sonnet|opus|haiku).
	Model string `yaml:"model"`
	// APIKeyEnvVar is the name of the environment variable containing the API key.
	APIKeyEnvVar string `yaml:"api_key_env_var"`
	// Timeout is the default timeout for AI operations.
	Timeout string `yaml:"timeout"`
	// MaxTurns is the maximum number of turns per AI step.
	MaxTurns int `yaml:"max_turns"`
}

AIConfig holds AI provider configuration. YAML field names match internal/config/config.go AIConfig struct.

type AIProviderConfig

type AIProviderConfig struct {
	// Model is the default Claude model to use (sonnet|opus|haiku).
	Model string
	// APIKeyEnvVar is the name of the environment variable containing the API key.
	APIKeyEnvVar string
	// Timeout is the default timeout for AI operations as a duration string.
	Timeout string
	// MaxTurns is the maximum number of turns per AI step.
	MaxTurns int
}

AIProviderConfig holds AI provider configuration values collected from user input. This struct is used for collecting configuration before saving.

func AIConfigDefaults

func AIConfigDefaults() AIProviderConfig

AIConfigDefaults returns the default values for AI configuration.

func CollectAIConfigNonInteractive

func CollectAIConfigNonInteractive() AIProviderConfig

CollectAIConfigNonInteractive returns a configuration with default values. Used when running in non-interactive mode.

type AnnotatedConfig

type AnnotatedConfig struct {
	AI            map[string]ConfigValueWithSource `json:"ai" yaml:"ai"`
	Git           map[string]ConfigValueWithSource `json:"git" yaml:"git"`
	Worktree      map[string]ConfigValueWithSource `json:"worktree" yaml:"worktree"`
	CI            map[string]ConfigValueWithSource `json:"ci" yaml:"ci"`
	Templates     map[string]ConfigValueWithSource `json:"templates" yaml:"templates"`
	Validation    map[string]ConfigValueWithSource `json:"validation" yaml:"validation"`
	Notifications map[string]ConfigValueWithSource `json:"notifications" yaml:"notifications"`
}

AnnotatedConfig represents configuration with source annotations.

type AtlasConfig

type AtlasConfig struct {
	AI            AIConfig           `yaml:"ai"`
	Validation    ValidationConfig   `yaml:"validation"`
	Notifications NotificationConfig `yaml:"notifications"`
	Hooks         HookConfig         `yaml:"hooks"`
}

AtlasConfig represents the user's ATLAS configuration. This is the structure that gets written to ~/.atlas/config.yaml.

type AtlasReleaseUpgrader added in v0.2.1

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

AtlasReleaseUpgrader handles upgrading atlas via GitHub releases.

func NewAtlasReleaseUpgrader added in v0.2.1

func NewAtlasReleaseUpgrader(executor config.CommandExecutor) *AtlasReleaseUpgrader

NewAtlasReleaseUpgrader creates a new AtlasReleaseUpgrader with default implementations.

func NewAtlasReleaseUpgraderWithDeps added in v0.2.1

func NewAtlasReleaseUpgraderWithDeps(client ReleaseClient, downloader ReleaseDownloader, executor config.CommandExecutor) *AtlasReleaseUpgrader

NewAtlasReleaseUpgraderWithDeps creates a new AtlasReleaseUpgrader with custom dependencies. This is used for testing.

func (*AtlasReleaseUpgrader) GetLatestVersion added in v0.2.1

func (u *AtlasReleaseUpgrader) GetLatestVersion(ctx context.Context) (string, error)

GetLatestVersion fetches the latest version from GitHub without upgrading.

func (*AtlasReleaseUpgrader) UpgradeAtlas added in v0.2.1

func (u *AtlasReleaseUpgrader) UpgradeAtlas(ctx context.Context, currentVersion string) (string, error)

UpgradeAtlas upgrades atlas to the latest release. Returns the new version string on success.

type AtlasUpgraderFunc added in v0.2.1

type AtlasUpgraderFunc func(executor config.CommandExecutor) *AtlasReleaseUpgrader

AtlasUpgraderFunc is a function type that creates an AtlasReleaseUpgrader. This allows injection of custom upgraders for testing.

type BuildInfo

type BuildInfo struct {
	// Version is the semantic version (e.g., "1.0.0").
	Version string
	// Commit is the git commit hash.
	Commit string
	// Date is the build date.
	Date string
}

BuildInfo contains version information set at build time via ldflags.

type CommandResult

type CommandResult struct {
	Command    string `json:"command"`
	Success    bool   `json:"success"`
	ExitCode   int    `json:"exit_code"`
	Output     string `json:"output,omitempty"`
	Error      string `json:"error,omitempty"`
	DurationMs int64  `json:"duration_ms"`
}

CommandResult holds the result of a single command execution.

type ConfigAIFlags

type ConfigAIFlags struct {
	// NoInteractive skips all prompts and shows current values.
	NoInteractive bool
}

ConfigAIFlags holds flags specific to the config ai command.

type ConfigNotificationFlags

type ConfigNotificationFlags struct {
	// NoInteractive skips all prompts and shows current values.
	NoInteractive bool
}

ConfigNotificationFlags holds flags specific to the config notifications command.

type ConfigShowFlags

type ConfigShowFlags struct {
	// OutputFormat specifies the output format (yaml or json).
	OutputFormat string
}

ConfigShowFlags holds flags specific to the config show command.

type ConfigSource

type ConfigSource string

ConfigSource represents where a configuration value came from.

const (
	// SourceDefault indicates the value is a built-in default.
	SourceDefault ConfigSource = "default"
	// SourceGlobal indicates the value came from global config.
	SourceGlobal ConfigSource = "global"
	// SourceProject indicates the value came from project config.
	SourceProject ConfigSource = "project"
	// SourceEnv indicates the value came from an environment variable.
	SourceEnv ConfigSource = "env"
)

type ConfigValidationFlags

type ConfigValidationFlags struct {
	// NoInteractive skips all prompts and shows current values.
	NoInteractive bool
}

ConfigValidationFlags holds flags specific to the config validation command.

type ConfigValueWithSource

type ConfigValueWithSource struct {
	Value  any          `json:"value" yaml:"value"`
	Source ConfigSource `json:"source" yaml:"source"`
}

ConfigValueWithSource represents a configuration value with its source.

type CryptoConfig added in v0.7.0

type CryptoConfig struct {
	Provider string `yaml:"provider"`
}

CryptoConfig holds cryptographic configuration.

type DefaultCommandExecutor

type DefaultCommandExecutor struct {
	config.DefaultCommandExecutor
}

DefaultCommandExecutor wraps config.DefaultCommandExecutor for use in upgrade.

type DefaultReleaseClient added in v0.2.1

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

DefaultReleaseClient implements ReleaseClient using gh CLI with HTTP fallback.

func NewDefaultReleaseClient added in v0.2.1

func NewDefaultReleaseClient(executor config.CommandExecutor) *DefaultReleaseClient

NewDefaultReleaseClient creates a new DefaultReleaseClient.

func NewDefaultReleaseClientWithHTTP added in v0.2.1

func NewDefaultReleaseClientWithHTTP(executor config.CommandExecutor, httpClient HTTPClient) *DefaultReleaseClient

NewDefaultReleaseClientWithHTTP creates a client with a custom HTTP client (for testing).

func (*DefaultReleaseClient) GetLatestRelease added in v0.2.1

func (c *DefaultReleaseClient) GetLatestRelease(ctx context.Context, owner, repo string) (*GitHubRelease, error)

GetLatestRelease fetches the latest release, trying gh first then falling back to HTTP.

type DefaultReleaseDownloader added in v0.2.1

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

DefaultReleaseDownloader implements ReleaseDownloader using gh CLI with HTTP fallback.

func NewDefaultReleaseDownloader added in v0.2.1

func NewDefaultReleaseDownloader(executor config.CommandExecutor) *DefaultReleaseDownloader

NewDefaultReleaseDownloader creates a new DefaultReleaseDownloader.

func NewDefaultReleaseDownloaderWithHTTP added in v0.2.1

func NewDefaultReleaseDownloaderWithHTTP(executor config.CommandExecutor, httpClient HTTPClient) *DefaultReleaseDownloader

NewDefaultReleaseDownloaderWithHTTP creates a downloader with a custom HTTP client.

func (*DefaultReleaseDownloader) DownloadFile added in v0.2.1

func (d *DefaultReleaseDownloader) DownloadFile(ctx context.Context, url string) (string, error)

DownloadFile downloads a file from URL to a temporary location. Tries gh CLI first (authenticated, works with private repos), falls back to HTTP.

type DefaultUpgradeChecker

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

DefaultUpgradeChecker implements UpgradeChecker using the tool detector.

func NewDefaultUpgradeChecker

func NewDefaultUpgradeChecker(executor config.CommandExecutor) *DefaultUpgradeChecker

NewDefaultUpgradeChecker creates a new DefaultUpgradeChecker.

func (*DefaultUpgradeChecker) CheckAllUpdates

func (c *DefaultUpgradeChecker) CheckAllUpdates(ctx context.Context) (*UpdateCheckResult, error)

CheckAllUpdates checks for updates to all tools in parallel.

func (*DefaultUpgradeChecker) CheckToolUpdate

func (c *DefaultUpgradeChecker) CheckToolUpdate(ctx context.Context, tool string) (*UpdateInfo, error)

CheckToolUpdate checks for updates to a specific tool.

type DefaultUpgradeExecutor

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

DefaultUpgradeExecutor implements UpgradeExecutor.

func NewDefaultUpgradeExecutor

func NewDefaultUpgradeExecutor(executor config.CommandExecutor) *DefaultUpgradeExecutor

NewDefaultUpgradeExecutor creates a new DefaultUpgradeExecutor.

func NewDefaultUpgradeExecutorWithUpgrader added in v0.2.1

func NewDefaultUpgradeExecutorWithUpgrader(executor config.CommandExecutor, upgraderFunc AtlasUpgraderFunc) *DefaultUpgradeExecutor

NewDefaultUpgradeExecutorWithUpgrader creates a new DefaultUpgradeExecutor with a custom atlas upgrader. This is used for testing.

func (*DefaultUpgradeExecutor) BackupConstitution

func (e *DefaultUpgradeExecutor) BackupConstitution() (string, error)

BackupConstitution backs up the Speckit constitution.md file.

func (*DefaultUpgradeExecutor) CleanupConstitutionBackup

func (e *DefaultUpgradeExecutor) CleanupConstitutionBackup(originalPath string) error

CleanupConstitutionBackup removes the constitution.md backup file.

func (*DefaultUpgradeExecutor) RestoreConstitution

func (e *DefaultUpgradeExecutor) RestoreConstitution(originalPath string) error

RestoreConstitution restores the Speckit constitution.md file from backup.

func (*DefaultUpgradeExecutor) UpgradeTool

func (e *DefaultUpgradeExecutor) UpgradeTool(ctx context.Context, tool string) (*UpgradeResult, error)

UpgradeTool upgrades a specific tool.

type ExecutionContext

type ExecutionContext struct {
	// WorkDir is the directory to operate on (worktree path or current repo root).
	WorkDir string

	// MainRepoPath is the path to the main repository (for config inheritance).
	MainRepoPath string

	// IsWorktree indicates if WorkDir is a linked worktree.
	IsWorktree bool

	// Config is the merged configuration.
	Config *config.Config
}

ExecutionContext holds resolved paths and config for command execution. It enables worktree-aware operation when the --worktree flag is used.

func ExecutionContextFrom added in v0.5.0

func ExecutionContextFrom(ctx context.Context) *ExecutionContext

ExecutionContextFrom retrieves the ExecutionContext from the context. Returns nil if no execution context was set or if type assertion fails. Callers must check for nil before calling methods on the result.

func ResolveExecutionContext

func ResolveExecutionContext(ctx context.Context, worktreeName string) (*ExecutionContext, error)

ResolveExecutionContext resolves the execution context from the worktree flag. If worktreeName is specified, finds and validates the worktree. Otherwise, uses current directory.

Config is loaded with worktree inheritance:

  • global config (~/.atlas/config.yaml) - lowest precedence
  • main repo config (<main-repo>/.atlas/config.yaml) - middle precedence
  • worktree config (<worktree>/.atlas/config.yaml) - highest precedence

func (*ExecutionContext) MainRepoConfigPath

func (ec *ExecutionContext) MainRepoConfigPath() string

MainRepoConfigPath returns the path to the main repository's config file.

func (*ExecutionContext) ProjectConfigPath

func (ec *ExecutionContext) ProjectConfigPath() string

ProjectConfigPath returns the path to the project config file for the execution context. Returns the worktree config path if in a worktree, otherwise the main repo config path.

type ExitCodeError

type ExitCodeError struct {
	Code int
	Err  error
}

ExitCodeError represents an error with a specific exit code.

func (*ExitCodeError) Error

func (e *ExitCodeError) Error() string

Error implements the error interface.

type GitHubRelease added in v0.2.1

type GitHubRelease struct {
	TagName     string         `json:"tag_name"`
	Name        string         `json:"name"`
	Assets      []ReleaseAsset `json:"assets"`
	PreRelease  bool           `json:"prerelease"`
	Draft       bool           `json:"draft"`
	PublishedAt string         `json:"published_at"`
}

GitHubRelease represents a GitHub release API response.

type GlobalFlags

type GlobalFlags struct {
	// Output specifies the output format (text or json).
	Output string
	// Verbose enables debug-level logging.
	Verbose bool
	// Quiet suppresses non-essential output (warn level only).
	Quiet bool
}

GlobalFlags holds flags available to all commands.

type HTTPClient added in v0.2.1

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient abstracts HTTP operations for testing.

type HookConfig added in v0.7.0

type HookConfig struct {
	Crypto CryptoConfig `yaml:"crypto"`
}

HookConfig holds hook system configuration.

type InitFlags

type InitFlags struct {
	// NoInteractive skips all prompts and uses default values.
	NoInteractive bool
	// Global forces configuration to be saved to global config only.
	Global bool
	// Project forces configuration to be saved to project config only.
	Project bool
}

InitFlags holds flags specific to the init command.

type NotificationConfig

type NotificationConfig struct {
	// BellEnabled enables terminal bell notifications.
	// Uses "bell" YAML tag to match internal/config/config.go for config.Load() compatibility.
	BellEnabled bool `yaml:"bell"`
	// Events is the list of events to notify on.
	Events []string `yaml:"events"`
}

NotificationConfig holds notification preferences. YAML field names match internal/config/config.go NotificationsConfig struct.

func DefaultNotificationConfig

func DefaultNotificationConfig() NotificationConfig

DefaultNotificationConfig returns a NotificationConfig with sensible defaults. Bell is enabled and granular events are selected (no legacy "error" event).

type NotificationProviderConfig

type NotificationProviderConfig struct {
	// BellEnabled enables terminal bell notifications.
	BellEnabled bool
	// Events is the list of events to notify on.
	Events []string
}

NotificationProviderConfig holds notification configuration values collected from user input. This struct is used for collecting configuration before saving.

func CollectNotificationConfigNonInteractive

func CollectNotificationConfigNonInteractive() NotificationProviderConfig

CollectNotificationConfigNonInteractive returns a configuration with default values. Used when running in non-interactive mode.

func NotificationConfigDefaults

func NotificationConfigDefaults() NotificationProviderConfig

NotificationConfigDefaults returns the default values for notification configuration. Uses granular events only (no legacy "error" event).

func (*NotificationProviderConfig) ToNotificationConfig

func (cfg *NotificationProviderConfig) ToNotificationConfig() NotificationConfig

ToNotificationConfig converts the provider config to NotificationConfig struct.

type ReleaseAsset added in v0.2.1

type ReleaseAsset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
	Size               int64  `json:"size"`
	ContentType        string `json:"content_type"`
}

ReleaseAsset represents a release asset from GitHub.

type ReleaseClient added in v0.2.1

type ReleaseClient interface {
	// GetLatestRelease fetches the latest release from GitHub.
	GetLatestRelease(ctx context.Context, owner, repo string) (*GitHubRelease, error)
}

ReleaseClient defines the interface for fetching GitHub release information. This allows mocking in tests.

type ReleaseDownloader added in v0.2.1

type ReleaseDownloader interface {
	// DownloadFile downloads a file from a URL to a temporary location.
	// Returns the path to the downloaded file.
	DownloadFile(ctx context.Context, url string) (string, error)
}

ReleaseDownloader defines the interface for downloading release assets. This allows mocking in tests.

type ResolvedGitConfig added in v0.5.0

type ResolvedGitConfig struct {
	CommitAgent         string
	CommitModel         string
	PRDescAgent         string
	PRDescModel         string
	CommitTimeout       time.Duration
	CommitMaxRetries    int
	CommitBackoffFactor float64
}

ResolvedGitConfig holds resolved agent/model settings for git operations. This consolidates the fallback logic for SmartCommit and PRDescription settings.

func ResolveGitConfig added in v0.5.0

func ResolveGitConfig(cfg *config.Config) ResolvedGitConfig

ResolveGitConfig resolves SmartCommit and PRDescription settings with fallback to global AI config. This eliminates duplicated resolution logic across commands.

type StatusDeps added in v0.5.0

type StatusDeps struct {
	WorkspaceMgr WorkspaceLister
	TaskStore    TaskLister
}

StatusDeps contains dependencies for status command execution. Using a struct enables easier testing with mock implementations.

type StatusRenderOptions added in v0.5.0

type StatusRenderOptions struct {
	Output       string
	Quiet        bool
	ShowProgress bool
}

StatusRenderOptions contains display-related options for status rendering. Using a struct reduces parameter count and improves readability.

type TaskLister

type TaskLister interface {
	List(ctx context.Context, workspaceName string) ([]*domain.Task, error)
}

TaskLister defines the interface for listing tasks. Used for dependency injection in tests.

type TaskLogAppender

type TaskLogAppender interface {
	AppendLog(ctx context.Context, workspaceName, taskID string, entry []byte) error
}

TaskLogAppender is a minimal interface for appending logs to task-specific log files. This interface is satisfied by task.Store.

type TemplateOverrideConfig

type TemplateOverrideConfig struct {
	// SkipTest indicates whether to skip tests for this template type.
	SkipTest bool `yaml:"skip_test"`
	// SkipLint indicates whether to skip linting for this template type.
	SkipLint bool `yaml:"skip_lint,omitempty"`
}

TemplateOverrideConfig holds per-template validation overrides.

type ToolDetector

type ToolDetector interface {
	Detect(ctx context.Context) (*config.ToolDetectionResult, error)
}

ToolDetector is an interface for detecting tools. This allows for mocking in tests.

type UpdateCheckResult

type UpdateCheckResult struct {
	// UpdatesAvailable indicates if any updates are available.
	UpdatesAvailable bool `json:"updates_available"`
	// Tools contains the update info for each tool.
	Tools []UpdateInfo `json:"tools"`
}

UpdateCheckResult contains the results of checking for updates.

type UpdateInfo

type UpdateInfo struct {
	// Name is the tool name.
	Name string `json:"name"`
	// CurrentVersion is the currently installed version.
	CurrentVersion string `json:"current_version"`
	// LatestVersion is the latest available version (may be empty if unknown).
	LatestVersion string `json:"latest_version,omitempty"`
	// UpdateAvailable indicates if an update is available.
	UpdateAvailable bool `json:"update_available"`
	// Installed indicates if the tool is currently installed.
	Installed bool `json:"installed"`
	// InstallPath is the go install path for the tool.
	InstallPath string `json:"-"`
}

UpdateInfo contains version information for a single tool.

type UpgradeChecker

type UpgradeChecker interface {
	// CheckAllUpdates checks for updates to all tools.
	CheckAllUpdates(ctx context.Context) (*UpdateCheckResult, error)
	// CheckToolUpdate checks for updates to a specific tool.
	CheckToolUpdate(ctx context.Context, tool string) (*UpdateInfo, error)
}

UpgradeChecker defines the interface for checking tool updates.

type UpgradeExecutor

type UpgradeExecutor interface {
	// UpgradeTool upgrades a specific tool.
	UpgradeTool(ctx context.Context, tool string) (*UpgradeResult, error)
	// BackupConstitution backs up the Speckit constitution.md file.
	BackupConstitution() (string, error)
	// RestoreConstitution restores the Speckit constitution.md file from backup.
	RestoreConstitution(originalPath string) error
	// CleanupConstitutionBackup removes the constitution.md backup file.
	CleanupConstitutionBackup(originalPath string) error
}

UpgradeExecutor defines the interface for executing tool upgrades.

type UpgradeFlags

type UpgradeFlags struct {
	// Check performs a dry-run, showing updates without installing.
	Check bool
	// Yes skips confirmation prompts.
	Yes bool
	// OutputFormat specifies the output format (text or json).
	OutputFormat string
}

UpgradeFlags holds flags specific to the upgrade command.

type UpgradeResult

type UpgradeResult struct {
	// Tool is the tool name.
	Tool string `json:"tool"`
	// Success indicates if the upgrade was successful.
	Success bool `json:"success"`
	// Error contains the error message if the upgrade failed.
	Error string `json:"error,omitempty"`
	// OldVersion is the version before upgrade.
	OldVersion string `json:"old_version"`
	// NewVersion is the version after upgrade (if successful).
	NewVersion string `json:"new_version,omitempty"`
	// Warnings contains non-fatal warning messages.
	Warnings []string `json:"warnings,omitempty"`
}

UpgradeResult contains the result of upgrading a single tool.

type UtilityOptions

type UtilityOptions struct {
	Verbose      bool
	OutputFormat string
	Writer       io.Writer
}

UtilityOptions holds options for utility command execution.

type ValidateOptions added in v0.10.0

type ValidateOptions struct {
	// Runner is an optional validation runner. If nil, a real one will be created.
	Runner ValidationRunner
	// WorkDir is an optional working directory. If empty, os.Getwd() is used.
	// This allows tests to avoid race conditions with directory changes.
	WorkDir string
}

ValidateOptions allows dependency injection for testing the validate command.

type ValidationCommands

type ValidationCommands struct {
	Format      []string `yaml:"format"`
	Lint        []string `yaml:"lint"`
	Test        []string `yaml:"test"`
	PreCommit   []string `yaml:"pre_commit"`
	CustomPrePR []string `yaml:"custom_pre_pr,omitempty"`
}

ValidationCommands holds the validation commands by category.

func SuggestValidationDefaults

func SuggestValidationDefaults(result *config.ToolDetectionResult) ValidationCommands

SuggestValidationDefaults suggests validation commands based on detected tools. This is the exported version of suggestValidationCommands for reuse.

type ValidationConfig

type ValidationConfig struct {
	Commands          ValidationCommands                `yaml:"commands"`
	TemplateOverrides map[string]TemplateOverrideConfig `yaml:"template_overrides,omitempty"`
}

ValidationConfig holds validation command configuration.

type ValidationProviderConfig

type ValidationProviderConfig struct {
	// FormatCmds is the multiline string of format commands (one per line).
	FormatCmds string
	// LintCmds is the multiline string of lint commands (one per line).
	LintCmds string
	// TestCmds is the multiline string of test commands (one per line).
	TestCmds string
	// PreCommitCmds is the multiline string of pre-commit commands (one per line).
	PreCommitCmds string
	// CustomPrePR is the multiline string of custom pre-PR hook commands (one per line).
	CustomPrePR string
}

ValidationProviderConfig holds validation configuration values collected from user input. This struct is used for collecting configuration before saving.

func CollectValidationConfigNonInteractive

func CollectValidationConfigNonInteractive(toolResult *config.ToolDetectionResult) ValidationProviderConfig

CollectValidationConfigNonInteractive returns a configuration with defaults based on detected tools. Used when running in non-interactive mode.

func ValidationConfigDefaults

func ValidationConfigDefaults() ValidationProviderConfig

ValidationConfigDefaults returns the default values for validation configuration. Defaults are empty as commands should be suggested based on detected tools.

func (*ValidationProviderConfig) ToValidationCommands

func (cfg *ValidationProviderConfig) ToValidationCommands() ValidationCommands

ToValidationCommands converts the provider config to ValidationCommands struct.

func (*ValidationProviderConfig) ToValidationConfig

func (cfg *ValidationProviderConfig) ToValidationConfig() ValidationConfig

ToValidationConfig converts the provider config to ValidationConfig struct.

type ValidationResponse

type ValidationResponse struct {
	Success      bool              `json:"success"`
	Results      []CommandResult   `json:"results"`
	SkippedSteps []string          `json:"skipped_steps,omitempty"`
	SkipReasons  map[string]string `json:"skip_reasons,omitempty"`
}

ValidationResponse is the JSON response for validation commands.

type ValidationRunner added in v0.10.0

type ValidationRunner interface {
	SetProgressCallback(cb validation.ProgressCallback)
	Run(ctx context.Context, workDir string) (*validation.PipelineResult, error)
}

ValidationRunner interface allows mocking the validation pipeline for tests.

type WorkspaceLister

type WorkspaceLister interface {
	List(ctx context.Context) ([]*domain.Workspace, error)
}

WorkspaceLister defines the interface for listing workspaces. Used for dependency injection in tests.

type WorkspaceTaskSelector added in v0.8.0

type WorkspaceTaskSelector interface {
	GetWorkspaceName() string
	GetTaskDescription() string
}

WorkspaceTaskSelector defines interface for items that can be selected from a workspace menu.

Directories

Path Synopsis
Package workflow provides workflow orchestration for ATLAS task execution.
Package workflow provides workflow orchestration for ATLAS task execution.

Jump to

Keyboard shortcuts

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