domain

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCharacterNameRequired = &ValidationError{
		Field:   "name",
		Message: "character name is required and cannot be empty",
	}

	ErrCharacterNameInvalid = &ValidationError{
		Field:   "name",
		Message: "character name must be a valid Go identifier (letters, numbers, underscore only, no hyphens or special characters)",
	}

	ErrInvalidDimensions = &ValidationError{
		Field:   "dimensions",
		Message: "character dimensions must be positive integers (width > 0, height > 0)",
	}

	ErrEmptyPattern = &ValidationError{
		Field:   "pattern",
		Message: "pattern cannot be empty",
	}

	ErrInvalidFrameCount = &ValidationError{
		Field:   "frames",
		Message: "frame count does not match character height",
	}

	ErrInvalidFrameName = &ValidationError{
		Field:   "frame_name",
		Message: "frame name cannot be empty",
	}

	ErrCharacterNotFound = &CharacterNotFoundError{}

	ErrPatternTooLong = &ValidationError{
		Field:   "pattern",
		Message: "pattern exceeds maximum length",
	}

	ErrInvalidPatternCharacter = &ValidationError{
		Field:   "pattern",
		Message: "pattern contains invalid characters",
	}
)

Domain-specific errors with helpful context

Functions

func GetErrorSuggestion

func GetErrorSuggestion(err error) string

Error suggestion helpers

Types

type AnimationError

type AnimationError struct {
	CharacterName string
	Operation     string
	Message       string
	Cause         error
}

func NewAnimationError

func NewAnimationError(characterName, operation, message string, cause error) *AnimationError

func (*AnimationError) Error

func (e *AnimationError) Error() string

func (*AnimationError) Unwrap

func (e *AnimationError) Unwrap() error

type Character

type Character struct {
	Name        string
	Personality string // Optional: "efficient", "friendly", "analytical", "creative"
	Color       string // Hex color for the character (e.g., "#FF4500")
	Width       int
	Height      int
	BaseFrame   Frame            // Idle/immutable base character
	States      map[string]State // Agent states (plan, think, execute, etc.)
	Frames      []Frame          // Keep for backward compatibility
}

Character represents a terminal character with frames and agent states

type CharacterNotFoundError

type CharacterNotFoundError struct {
	Name string
}

func NewCharacterNotFoundError

func NewCharacterNotFoundError(name string) *CharacterNotFoundError

func (*CharacterNotFoundError) Error

func (e *CharacterNotFoundError) Error() string

type CharacterSpec

type CharacterSpec struct {
	Name   string
	Width  int
	Height int
	Frames []FrameSpec
}

CharacterSpec represents the specification for creating a character

func NewCharacterSpec

func NewCharacterSpec(name string, width, height int) *CharacterSpec

NewCharacterSpec creates a new character specification

func (*CharacterSpec) AddFrame

func (cs *CharacterSpec) AddFrame(name string, patterns []string) *CharacterSpec

AddFrame adds a frame to a character specification

func (*CharacterSpec) AddFrameFromString

func (cs *CharacterSpec) AddFrameFromString(name, pattern string) *CharacterSpec

AddFrameFromString adds a frame from a single string pattern

type Frame

type Frame struct {
	Name  string
	Lines []string
}

Frame represents a single frame of animation

type FrameSpec

type FrameSpec struct {
	Name     string
	Patterns []string
}

FrameSpec represents the specification for a single frame

type PatternCompilationError

type PatternCompilationError struct {
	Pattern  string
	Position int
	Message  string
	Cause    error
}

func NewPatternCompilationError

func NewPatternCompilationError(pattern string, position int, message string, cause error) *PatternCompilationError

func (*PatternCompilationError) Error

func (e *PatternCompilationError) Error() string

func (*PatternCompilationError) Unwrap

func (e *PatternCompilationError) Unwrap() error

type PatternCompiler

type PatternCompiler interface {
	Compile(pattern string) string
	Validate(pattern string) error
}

PatternCompiler defines the interface for pattern compilation

type State

type State struct {
	Name           string
	Description    string
	Frames         []Frame // Multiple frames for animation
	StateType      string  // "standard" or "custom"
	AnimationFPS   int     // FPS for this state (default: 5)
	AnimationLoops int     // Loop count for this state (default: 1)
}

State represents an agent behavioral state

type ValidationError

type ValidationError struct {
	Field   string
	Value   interface{}
	Message string
	Cause   error
}

Error types for better error handling

func NewValidationError

func NewValidationError(field string, value interface{}, message string) *ValidationError

Helper functions to create contextual errors

func NewValidationErrorWithCause

func NewValidationErrorWithCause(field string, value interface{}, message string, cause error) *ValidationError

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Jump to

Keyboard shortcuts

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