template

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package template provides task template management for ATLAS.

Package template provides task template management for ATLAS. Templates define the sequence of steps for automated task execution.

Package template provides template loading, validation, and registry functionality.

Index

Constants

This section is empty.

Variables

View Source
var DefaultValidationCommands = []string{
	"magex format:fix",
	"magex lint",
	"magex test:race",
	"go-pre-commit run --all-files --skip lint",
}

DefaultValidationCommands are the standard validation commands used across all templates. These can be overridden per-template.

Functions

func ApplyConfig

func ApplyConfig(t *domain.Template, cfg *config.Config) *domain.Template

ApplyConfig applies configuration overrides to a template. Returns a new template with the overrides applied (original is not modified).

func ApplyOverrides

func ApplyOverrides(t *domain.Template, overrides Overrides) *domain.Template

ApplyOverrides applies explicit overrides to a template. This is useful when CLI flags or other sources provide overrides. Returns a new template with the overrides applied (original is not modified).

func CIWaitStep added in v0.5.0

func CIWaitStep() domain.StepDefinition

CIWaitStep creates a standard CI wait step.

func GitCommitStep added in v0.5.0

func GitCommitStep(description string) domain.StepDefinition

GitCommitStep creates a standard git commit step with the given description.

func GitPRStep added in v0.5.0

func GitPRStep() domain.StepDefinition

GitPRStep creates a standard git pull request step.

func GitPushStep added in v0.5.0

func GitPushStep() domain.StepDefinition

GitPushStep creates a standard git push step.

func IsValidStepType

func IsValidStepType(t domain.StepType) bool

IsValidStepType checks if the step type is a known valid type.

func NewBugTemplate added in v0.11.0

func NewBugTemplate() *domain.Template

NewBugTemplate creates the consolidated bug template for fixing bugs.

This template intelligently selects between two modes based on description length:

With description (>20 chars): analyze → implement → verify → validate → git workflow

When the user provides a bug description, we analyze the bug report first.

Without description (≤20 chars): detect → implement → verify → validate → git workflow

When the user provides just "fix lint" or similar, we detect issues first.

Steps use skip_condition to automatically select the appropriate path:

  • "detect" step: skipped when has_description (user described the bug)
  • "analyze" step: skipped when no_description (detect mode)

The implement step receives context from whichever analysis step ran:

  • From analyze: the bug analysis and root cause
  • From detect: the validation errors to fix

func NewCommitTemplate

func NewCommitTemplate() *domain.Template

NewCommitTemplate creates the commit template for smart commits. Steps: analyze_changes → smart_commit → git_push

func NewFeatureTemplate

func NewFeatureTemplate() *domain.Template

NewFeatureTemplate creates the feature template with Speckit SDD integration. Steps: specify → review_spec → plan → tasks → implement → verify → validate →

checklist → git_commit → git_push → git_pr → ci_wait → review

func NewPatchTemplate added in v0.11.0

func NewPatchTemplate() *domain.Template

NewPatchTemplate creates the patch template for fixing issues on existing branches. This template is designed for scenarios where a PR already exists and needs quick fixes.

Unlike other templates that create a new branch and PR, the patch template: - Expects to work on an existing branch (use --target flag) - Does NOT create a PR (the branch is already in a PR) - Pushes directly to the target branch

Workflow: 1. detect: Runs validation in detect_only mode to find issues (optional) 2. fix: AI receives the actual validation errors and fixes them 3. validate: Confirms all fixes work 4. git_commit: Commits the changes 5. git_push: Pushes to the target branch (no PR creation)

Usage:

atlas start "fix lint errors" --template patch --target feat/my-feature

func NewTaskTemplate

func NewTaskTemplate() *domain.Template

NewTaskTemplate creates the task template for generic simple tasks. Steps: implement → verify (optional) → validate → git_commit → git_push → git_pr → ci_wait → review

func ParseStepType

func ParseStepType(s string) (domain.StepType, error)

ParseStepType converts a string to a StepType with validation. The conversion is case-insensitive.

func ReviewStep added in v0.5.0

func ReviewStep(prompt string) domain.StepDefinition

ReviewStep creates a standard human review step with the given prompt.

func StandardGitWorkflowSteps added in v0.5.0

func StandardGitWorkflowSteps(commitDescription, reviewPrompt string) []domain.StepDefinition

StandardGitWorkflowSteps returns the common git workflow steps: git_commit -> git_push -> git_pr -> ci_wait -> review

commitDescription describes what is being committed (e.g., "fix changes", "feature changes"). reviewPrompt is the prompt shown during human review.

func ValidStepTypes

func ValidStepTypes() []domain.StepType

ValidStepTypes returns all valid step type values.

func ValidateTemplate

func ValidateTemplate(t *domain.Template) error

ValidateTemplate validates a template has all required fields and valid values. Returns nil if the template is valid, otherwise returns a descriptive error.

func ValidationStep added in v0.5.0

func ValidationStep() domain.StepDefinition

ValidationStep creates a standard validation step.

func VerifyStep added in v0.5.0

func VerifyStep(agent string, checks []string, required bool) domain.StepDefinition

VerifyStep creates an optional AI verification step. agent specifies which AI agent to use for verification (e.g., "gemini"). checks specifies which verification checks to run.

func WithConfig added in v0.5.0

func WithConfig(r *Registry, name string, cfg *config.Config) (*domain.Template, error)

WithConfig retrieves a template from the registry and applies config overrides. This is the main entry point for getting a ready-to-use template.

Types

type FileStepDefinition

type FileStepDefinition struct {
	Name        string         `yaml:"name" json:"name"`
	Type        string         `yaml:"type" json:"type"`
	Description string         `yaml:"description,omitempty" json:"description,omitempty"`
	Required    bool           `yaml:"required" json:"required"`
	Timeout     string         `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	RetryCount  int            `yaml:"retry_count,omitempty" json:"retry_count,omitempty"`
	Config      map[string]any `yaml:"config,omitempty" json:"config,omitempty"`
}

FileStepDefinition represents a step in the YAML/JSON file.

type FileTemplate

type FileTemplate struct {
	Name               string                          `yaml:"name" json:"name"`
	Description        string                          `yaml:"description" json:"description"`
	BranchPrefix       string                          `yaml:"branch_prefix" json:"branch_prefix"`
	DefaultAgent       string                          `yaml:"default_agent,omitempty" json:"default_agent,omitempty"`
	DefaultModel       string                          `yaml:"default_model,omitempty" json:"default_model,omitempty"`
	Steps              []FileStepDefinition            `yaml:"steps" json:"steps"`
	ValidationCommands []string                        `yaml:"validation_commands,omitempty" json:"validation_commands,omitempty"`
	Variables          map[string]FileTemplateVariable `yaml:"variables,omitempty" json:"variables,omitempty"`
	Verify             bool                            `yaml:"verify,omitempty" json:"verify,omitempty"`
	VerifyModel        string                          `yaml:"verify_model,omitempty" json:"verify_model,omitempty"`
}

FileTemplate represents the YAML/JSON structure for custom templates. Field names use both yaml and json tags for dual format support.

type FileTemplateVariable

type FileTemplateVariable struct {
	Description string `yaml:"description,omitempty" json:"description,omitempty"`
	Default     string `yaml:"default,omitempty" json:"default,omitempty"`
	Required    bool   `yaml:"required" json:"required"`
}

FileTemplateVariable represents a variable in the YAML/JSON file.

type Loader

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

Loader loads templates from files.

func NewLoader

func NewLoader(basePath string) *Loader

NewLoader creates a new template loader. basePath is used to resolve relative template paths (typically project root).

func (*Loader) LoadAll

func (l *Loader) LoadAll(templates map[string]string) ([]*domain.Template, error)

LoadAll loads multiple templates from name->path mappings. The configName (map key) is used as the template name if different from the file's name field. Returns an error on the first failure (fail-fast behavior).

func (*Loader) LoadFromFile

func (l *Loader) LoadFromFile(path string) (*domain.Template, error)

LoadFromFile loads a template from a YAML or JSON file. The format is auto-detected based on file extension (.json for JSON, otherwise YAML). Returns an error if the file cannot be read, parsed, or validated.

type Overrides

type Overrides struct {
	// Agent overrides the template's default AI agent (claude, gemini).
	Agent domain.Agent

	// Model overrides the template's default AI model.
	Model string

	// BranchPrefix overrides the template's branch prefix.
	BranchPrefix string

	// AutoProceedGit indicates whether git operations should proceed automatically.
	AutoProceedGit bool
}

Overrides contains template-specific configuration overrides.

type Registry

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

Registry provides thread-safe access to task templates. Templates are stored by name and can be retrieved or listed. Aliases can map alternative names to existing templates.

func NewDefaultRegistry

func NewDefaultRegistry() *Registry

NewDefaultRegistry creates a registry with all built-in templates. Templates are compiled into the binary (not external files). Panics if any template registration fails (indicates programming error).

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new empty template registry.

func NewRegistryWithConfig

func NewRegistryWithConfig(basePath string, customTemplates map[string]string) (*Registry, error)

NewRegistryWithConfig creates a registry with built-in templates and custom templates from config. Custom templates are loaded from file paths specified in the customTemplates map. If a custom template has the same name as a built-in, the custom template takes precedence.

basePath is used to resolve relative template paths (typically the project root). customTemplates maps template names to their file paths.

Returns an error on the first template loading failure (fail-fast behavior).

func (*Registry) Aliases added in v0.11.0

func (r *Registry) Aliases() map[string]string

Aliases returns all registered aliases as a map from alias to target template name.

func (*Registry) Get

func (r *Registry) Get(name string) (*domain.Template, error)

Get retrieves a template by name or alias. Returns a clone of the template to prevent mutation of registry state. Returns ErrTemplateNotFound if the template doesn't exist.

func (*Registry) IsAlias added in v0.11.0

func (r *Registry) IsAlias(name string) bool

IsAlias returns true if the given name is a registered alias.

func (*Registry) List

func (r *Registry) List() []*domain.Template

List returns all registered templates. The returned slice and templates are clones, safe to modify without affecting the registry.

func (*Registry) Register

func (r *Registry) Register(t *domain.Template) error

Register adds a template to the registry. Returns error if template is nil, has empty name, or already exists.

func (*Registry) RegisterAlias added in v0.11.0

func (r *Registry) RegisterAlias(alias, target string) error

RegisterAlias creates an alias that points to an existing template. When Get is called with the alias name, it returns the target template. Returns error if: - alias or target is empty - target template doesn't exist - alias name conflicts with an existing template name

func (*Registry) RegisterOrReplace

func (r *Registry) RegisterOrReplace(t *domain.Template) error

RegisterOrReplace adds a template to the registry, replacing any existing template with the same name. This is used for custom templates that should override built-in templates. Returns error if template is nil or has empty name.

type VariableExpander

type VariableExpander struct{}

VariableExpander handles template variable substitution.

func NewVariableExpander

func NewVariableExpander() *VariableExpander

NewVariableExpander creates a new variable expander.

func (*VariableExpander) Expand

func (e *VariableExpander) Expand(t *domain.Template, values map[string]string) (*domain.Template, error)

Expand substitutes variables in a template with provided values. Missing required variables result in an error. Optional variables without values use their defaults. Returns a cloned template with expanded values.

Directories

Path Synopsis
Package steps provides step execution implementations for the ATLAS task engine.
Package steps provides step execution implementations for the ATLAS task engine.

Jump to

Keyboard shortcuts

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