models

package
v0.0.0-...-fdf23f2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHookTypesInOrder

func GetHookTypesInOrder() []string

GetHookTypesInOrder returns hook types in the order they should be processed

func GetUserFriendlyMessage

func GetUserFriendlyMessage(err error) string

GetUserFriendlyMessage returns a user-friendly error message

func IsErrorCode

func IsErrorCode(err error, code ErrorCode) bool

IsErrorCode checks if the error has the specified error code

func IsFileSystemError

func IsFileSystemError(err error) bool

IsFileSystemError checks if the error is a file system related error

func IsGitError

func IsGitError(err error) bool

IsGitError checks if the error is a git-related error

func IsStrategicHook

func IsStrategicHook(command string) bool

IsStrategicHook checks if a hook command is one of our strategic hooks

Types

type AppError

type AppError struct {
	Code    ErrorCode              `json:"code"`
	Message string                 `json:"message"`
	Cause   error                  `json:"-"` // Original error, not serialized
	Context map[string]interface{} `json:"context,omitempty"`
}

AppError represents a structured application error

func NewAppError

func NewAppError(code ErrorCode, message string, cause error) *AppError

NewAppError creates a new application error

func NewFileSystemError

func NewFileSystemError(code ErrorCode, path string, cause error) *AppError

NewFileSystemError creates a file system related error

func NewGitError

func NewGitError(code ErrorCode, operation string, cause error) *AppError

NewGitError creates a git-related error

func NewInstallationError

func NewInstallationError(code ErrorCode, targetDir string, cause error) *AppError

NewInstallationError creates an installation-related error

func NewValidationError

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

NewValidationError creates a validation error

func (*AppError) Error

func (e *AppError) Error() string

Error implements the error interface

func (*AppError) Is

func (e *AppError) Is(target error) bool

Is checks if the error matches the target error code

func (*AppError) Unwrap

func (e *AppError) Unwrap() error

Unwrap returns the underlying error

func (*AppError) WithContext

func (e *AppError) WithContext(key string, value interface{}) *AppError

WithContext adds context information to the error

type ClaudeSettings

type ClaudeSettings struct {
	Hooks       *HooksSection       `json:"hooks,omitempty"`
	Permissions *PermissionsSection `json:"permissions,omitempty"`
}

ClaudeSettings represents the structure of Claude Code settings.json

type CleanConfig

type CleanConfig struct {
	// Target directory for cleanup
	TargetDir string

	// Cleanup behavior flags
	Force   bool // Force cleanup without confirmation
	Verbose bool // Enable verbose output
	DryRun  bool // Show what would be done without making changes

	// Preserve user content during cleanup
	PreserveUserContent bool
}

CleanConfig holds configuration options for cleanup operations

func NewCleanConfig

func NewCleanConfig(targetDir string) *CleanConfig

NewCleanConfig creates a new CleanConfig with default values

type ErrorCode

type ErrorCode string

ErrorCode represents different types of errors that can occur

const (
	// Git operation errors
	ErrorCodeGitCloneFailed    ErrorCode = "GIT_CLONE_FAILED"
	ErrorCodeGitCheckoutFailed ErrorCode = "GIT_CHECKOUT_FAILED"
	ErrorCodeGitNotInstalled   ErrorCode = "GIT_NOT_INSTALLED"
	ErrorCodeGitNotFound       ErrorCode = "GIT_NOT_FOUND"
	ErrorCodeGitCloneError     ErrorCode = "GIT_CLONE_ERROR"
	ErrorCodeGitCheckoutError  ErrorCode = "GIT_CHECKOUT_ERROR"
	ErrorCodeGitError          ErrorCode = "GIT_ERROR"
	ErrorCodeGitCommitNotFound ErrorCode = "GIT_COMMIT_NOT_FOUND"

	// File system errors
	ErrorCodeFileSystemError       ErrorCode = "FILE_SYSTEM_ERROR"
	ErrorCodeDirectoryNotFound     ErrorCode = "DIRECTORY_NOT_FOUND"
	ErrorCodeDirectoryNotEmpty     ErrorCode = "DIRECTORY_NOT_EMPTY"
	ErrorCodePermissionDenied      ErrorCode = "PERMISSION_DENIED"
	ErrorCodeFileAlreadyExists     ErrorCode = "FILE_ALREADY_EXISTS"
	ErrorCodeSymlinkCreationFailed ErrorCode = "SYMLINK_CREATION_FAILED"
	ErrorCodeSymlinkInvalid        ErrorCode = "SYMLINK_INVALID"

	// Installation errors
	ErrorCodeInstallationFailed ErrorCode = "INSTALLATION_FAILED"
	ErrorCodeAlreadyInstalled   ErrorCode = "ALREADY_INSTALLED"
	ErrorCodeNotInstalled       ErrorCode = "NOT_INSTALLED"
	ErrorCodeBackupFailed       ErrorCode = "BACKUP_FAILED"
	ErrorCodeRestoreFailed      ErrorCode = "RESTORE_FAILED"

	// Validation errors
	ErrorCodeInvalidPath          ErrorCode = "INVALID_PATH"
	ErrorCodeInvalidConfiguration ErrorCode = "INVALID_CONFIGURATION"
	ErrorCodeValidationFailed     ErrorCode = "VALIDATION_FAILED"

	// Network errors
	ErrorCodeNetworkTimeout ErrorCode = "NETWORK_TIMEOUT"
	ErrorCodeNetworkError   ErrorCode = "NETWORK_ERROR"

	// User interaction errors
	ErrorCodeUserCancelled ErrorCode = "USER_CANCELLED"
	ErrorCodeInputError    ErrorCode = "INPUT_ERROR"
)

type HookEntry

type HookEntry struct {
	Type    string `json:"type"`
	Command string `json:"command"`
}

HookEntry represents an individual hook configuration

type HookMatcher

type HookMatcher struct {
	Matcher string      `json:"matcher"`
	Hooks   []HookEntry `json:"hooks"`
}

HookMatcher represents a matcher pattern with associated hooks

type HooksSection

type HooksSection struct {
	PreToolUse   []HookMatcher `json:"PreToolUse,omitempty"`
	PostToolUse  []HookMatcher `json:"PostToolUse,omitempty"`
	Stop         []HookMatcher `json:"Stop,omitempty"`
	PreCompact   []HookMatcher `json:"PreCompact,omitempty"`
	Notification []HookMatcher `json:"Notification,omitempty"`
}

HooksSection contains all hook type configurations

type InstallConfig

type InstallConfig struct {
	// Target directory for installation
	TargetDir string

	// Template selection
	TemplateID string // ID of the template to install

	// Installation behavior flags
	Force         bool   // Force installation, overwriting existing files
	ForceCore     bool   // Update only core framework files, preserving user content
	SkipConfirm   bool   // Skip confirmation prompts (--yes flag)
	NoBackup      bool   // Skip creating backups of existing files
	DryRun        bool   // Show what would be done without making changes
	Verbose       bool   // Enable verbose output
	GitignoreMode string // Gitignore behavior: "track", "all", or "non-user"

	// Optional custom backup directory
	BackupDir string

	// Timeout for git operations
	GitTimeout time.Duration
}

InstallConfig holds configuration options for installation operations

func NewInstallConfig

func NewInstallConfig(targetDir string) *InstallConfig

NewInstallConfig creates a new InstallConfig with default values

func (*InstallConfig) GetTemplate

func (c *InstallConfig) GetTemplate() (templates.Template, error)

GetTemplate returns the template configuration for this install

func (*InstallConfig) IsSelectiveUpdate

func (c *InstallConfig) IsSelectiveUpdate() bool

IsSelectiveUpdate returns true if this is a selective core-only update

func (*InstallConfig) ShouldCreateBackup

func (c *InstallConfig) ShouldCreateBackup() bool

ShouldCreateBackup returns true if backups should be created

func (*InstallConfig) ShouldPromptUser

func (c *InstallConfig) ShouldPromptUser() bool

ShouldPromptUser returns true if user prompts should be shown

func (*InstallConfig) Validate

func (c *InstallConfig) Validate() error

Validate checks that the configuration is valid

type InstallationPlan

type InstallationPlan struct {
	// Basic information
	TargetDir        string           `json:"target_dir"`
	InstallationType InstallationType `json:"installation_type"`

	// Template information
	Template templates.Template `json:"template"`

	// Script information
	HasPreInstallScript  bool `json:"has_pre_install_script"`
	HasPostInstallScript bool `json:"has_post_install_script"`

	// File operations
	ExistingFiles []string `json:"existing_files"` // Files that already exist
	WillReplace   []string `json:"will_replace"`   // Files that will be replaced
	WillPreserve  []string `json:"will_preserve"`  // Files that will be preserved
	WillCreate    []string `json:"will_create"`    // New files that will be created

	// Directory operations
	DirectoriesToCreate []string `json:"directories_to_create"`
	SymlinksToCreate    []string `json:"symlinks_to_create"`
	SymlinksToUpdate    []string `json:"symlinks_to_update"`

	// Backup information
	BackupRequired bool   `json:"backup_required"`
	BackupDir      string `json:"backup_dir,omitempty"`

	// Validation results
	HasConflicts bool     `json:"has_conflicts"`
	Warnings     []string `json:"warnings,omitempty"`
	Errors       []string `json:"errors,omitempty"`
}

InstallationPlan represents what will happen during an installation

func NewInstallationPlan

func NewInstallationPlan(targetDir string, installType InstallationType, template templates.Template) *InstallationPlan

NewInstallationPlan creates a new InstallationPlan for the given target directory and template

func (*InstallationPlan) AddError

func (p *InstallationPlan) AddError(err string)

AddError adds an error to the installation plan

func (*InstallationPlan) AddWarning

func (p *InstallationPlan) AddWarning(warning string)

AddWarning adds a warning to the installation plan

func (*InstallationPlan) IsValid

func (p *InstallationPlan) IsValid() bool

IsValid returns true if the installation plan has no errors

func (*InstallationPlan) RequiresConfirmation

func (p *InstallationPlan) RequiresConfirmation() bool

RequiresConfirmation returns true if the plan requires user confirmation

type InstallationType

type InstallationType string

InstallationType represents the type of installation operation

const (
	InstallationTypeNew       InstallationType = "New Installation"
	InstallationTypeUpdate    InstallationType = "Update Core Only"
	InstallationTypeOverwrite InstallationType = "Full Overwrite"
)

type MCPConfig

type MCPConfig struct {
	MCPServers map[string]MCPServer `json:"mcpServers"`
}

MCPConfig represents the structure of an .mcp.json file

type MCPInstallationPlan

type MCPInstallationPlan struct {
	TargetDir       string        // Directory where .mcp.json will be created/updated
	SelectedMCPs    []MCPTemplate // MCPs selected for installation
	HasExistingMCP  bool          // Whether .mcp.json already exists
	ExistingMCPPath string        // Path to existing .mcp.json
	BackupPath      string        // Path where backup will be created
	TemplatesDir    string        // Path to MCP templates directory
}

MCPInstallationPlan represents what will be installed

func (*MCPInstallationPlan) Validate

func (p *MCPInstallationPlan) Validate() error

Validate validates an MCP installation plan

type MCPServer

type MCPServer struct {
	Command string            `json:"command"`
	Args    []string          `json:"args"`
	Env     map[string]string `json:"env,omitempty"`
}

MCPServer represents a single MCP server configuration

type MCPTemplate

type MCPTemplate struct {
	Name     string    // Display name (extracted from filename)
	FileName string    // Full filename (e.g., "context7.mcp.json")
	Server   MCPServer // Server configuration from the template file
}

MCPTemplate represents an available MCP template for installation

type PermissionsSection

type PermissionsSection struct {
	Allow                 []string `json:"allow,omitempty"`
	AdditionalDirectories []string `json:"additionalDirectories,omitempty"`
}

PermissionsSection contains Claude Code permissions

type StatusInfo

type StatusInfo struct {
	// Basic installation status
	IsInstalled        bool `json:"is_installed"`
	StrategicClaudeDir bool `json:"strategic_claude_dir_exists"`
	ClaudeDir          bool `json:"claude_dir_exists"`

	// Template information
	InstalledTemplate *templates.TemplateInfo `json:"installed_template,omitempty"`

	// Script detection
	HasPreInstallScript  bool `json:"has_pre_install_script"`
	HasPostInstallScript bool `json:"has_post_install_script"`

	// Detailed component status
	Symlinks []SymlinkStatus `json:"symlinks"`
	Issues   []string        `json:"issues"`

	// Installation metadata (deprecated - use InstalledTemplate instead)
	InstallationDate *time.Time `json:"installation_date,omitempty"`
	Version          string     `json:"version,omitempty"`
	CommitHash       string     `json:"commit_hash,omitempty"`

	// Directory paths
	TargetDir              string `json:"target_dir"`
	StrategicClaudeDirPath string `json:"strategic_claude_dir_path"`
	ClaudeDirPath          string `json:"claude_dir_path"`
}

StatusInfo represents the overall installation status

func NewStatusInfo

func NewStatusInfo(targetDir string) *StatusInfo

NewStatusInfo creates a new StatusInfo for the given target directory

func (*StatusInfo) AddIssue

func (s *StatusInfo) AddIssue(issue string)

AddIssue adds an issue to the status info

func (s *StatusInfo) AddSymlink(symlink SymlinkStatus)

AddSymlink adds a symlink status to the status info

func (*StatusInfo) HasIssues

func (s *StatusInfo) HasIssues() bool

HasIssues returns true if there are any issues

func (s *StatusInfo) ValidSymlinks() int

ValidSymlinks returns the number of valid symlinks

type SymlinkStatus

type SymlinkStatus struct {
	Name   string `json:"name"`            // Name of the symlink (e.g., "core", "guides")
	Path   string `json:"path"`            // Full path to the symlink
	Valid  bool   `json:"valid"`           // Whether the symlink is valid and points to the right target
	Target string `json:"target"`          // Target path the symlink points to
	Exists bool   `json:"exists"`          // Whether the symlink file exists
	Error  string `json:"error,omitempty"` // Error message if validation failed
}

SymlinkStatus represents the status of an individual symlink

Jump to

Keyboard shortcuts

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