domain

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HoursPerDay is the number of hours in a day.
	HoursPerDay = 24

	// DurationRegexSubmatches is the expected number of regex submatches for days duration.
	DurationRegexSubmatches = 2
)

Duration parsing constants.

View Source
const (
	// PathSystem is the macOS system directory.
	PathSystem = "/System"
	// PathApplications is the macOS applications directory.
	PathApplications = "/Applications"
	// PathLibrary is the macOS library directory.
	PathLibrary = "/Library"
	// PathRoot is the root directory.
	PathRoot = "/"
	// PathUser is the user directory.
	PathUser = "/usr"
	// PathEtc is the etc directory.
	PathEtc = "/etc"
	// PathVar is the var directory.
	PathVar = "/var"
)

SystemPaths contains protected system path constants to avoid magic strings.

View Source
const (
	// GenerationBaseSizeMB is the base estimated size per generation in MB.
	GenerationBaseSizeMB = 50
	// GenerationAgeFactorMB is the additional size per month of age in MB.
	GenerationAgeFactorMB = 10
	// DaysPerMonth is the average number of days per month.
	DaysPerMonth = 30

	// Byte conversion constants.
	BytesPerKB = 1024
	BytesPerMB = 1024 * 1024
)

Size estimation constants for generation size calculations.

Variables

View Source
var (
	RiskLow      = RiskLevelLowType
	RiskMedium   = RiskLevelMediumType
	RiskHigh     = RiskLevelHighType
	RiskCritical = RiskLevelCriticalType

	ValidationLevelNone          = ValidationLevelNoneType
	ValidationLevelBasic         = ValidationLevelBasicType
	ValidationLevelComprehensive = ValidationLevelComprehensiveType
	ValidationLevelStrict        = ValidationLevelStrictType

	OperationAdded    = ChangeOperationAddedType
	OperationRemoved  = ChangeOperationRemovedType
	OperationModified = ChangeOperationModifiedType

	StrategyAggressive   = StrategyAggressiveType
	StrategyConservative = StrategyConservativeType
	StrategyDryRun       = StrategyDryRunType
)

Use type-safe constants directly.

View Source
var DefaultBinaryExtensions = []string{

	"",
	".exe",
	".dll",
	".so",
	".dylib",
	".a",
	".o",
	".out",
	".app",

	".test",
	".bench",
	".prof",

	".zip",
	".tar",
	".gz",
	".bz2",
	".xz",
	".7z",
	".rar",

	".db",
	".sqlite",
	".sqlite3",

	".bin",
	".dat",
	".data",

	".wasm",
	".class",
	".jar",
}

DefaultBinaryExtensions are binary extensions commonly found in git history that should be cleaned.

View Source
var ExtensionsToKeep = []string{
	".pdf",
	".png",
	".jpg",
	".jpeg",
	".gif",
	".svg",
	".ico",
	".woff",
	".woff2",
	".ttf",
	".eot",
	".mp3",
	".mp4",
	".webm",
	".webp",
}

ExtensionsToKeep are binary extensions that should typically NOT be removed.

Functions

func AllProtectedSystemPaths

func AllProtectedSystemPaths() []string

AllProtectedSystemPaths returns all protected system paths including non-critical ones.

func CriticalSystemPaths

func CriticalSystemPaths() []string

CriticalSystemPaths returns all critical system paths that should never be deleted.

func DefaultProtectedPaths

func DefaultProtectedPaths() []string

DefaultProtectedPaths returns the default protected system paths.

func EnumIsValid

func EnumIsValid[T ~int](val, maxVal T) bool

func EnumMarshalJSON

func EnumMarshalJSON[T ~int](val T, stringsMap []string) ([]byte, error)

func EnumMarshalYAML

func EnumMarshalYAML[T ~int](val T, stringsMap []string) (any, error)

func EnumString

func EnumString[T ~int](val T, stringsMap []string) string

func EnumUnmarshalJSON

func EnumUnmarshalJSON[T ~int](
	data []byte,
	target *T,
	stringsMap []string,
	name string,
) error

func EnumUnmarshalYAML

func EnumUnmarshalYAML[T ~int](
	value *yaml.Node,
	target *T,
	stringsMap []string,
	name string,
) error

func EnumValues

func EnumValues[T ~int](maxVal T) []T

func IsProtectedPath

func IsProtectedPath(path string, protected []string) bool

IsProtectedPath checks if a path is in the protected paths list.

func ParseCustomDuration

func ParseCustomDuration(durationStr string) (time.Duration, error)

ParseCustomDuration parses human-readable duration formats like "7d", "24h", "30m" and converts them to Go time.Duration.

func SortBySizeDesc

func SortBySizeDesc(files []GitHistoryFile)

SortBySizeDesc sorts files by size in descending order.

func ValidateCustomDuration

func ValidateCustomDuration(durationStr string) error

ValidateCustomDuration checks if a duration string is valid for this system.

Types

type BuildCacheSettings

type BuildCacheSettings struct {
	ToolTypes []BuildToolType `json:"tool_types,omitempty" yaml:"tool_types,omitempty"`
	OlderThan string          `json:"older_than,omitempty" yaml:"older_than,omitempty"`
}

BuildCacheSettings provides type-safe settings for build cache cleanup.

type BuildToolType

type BuildToolType int

BuildToolType represents build tool types as a type-safe enum.

const (
	// BuildToolGo represents Go build tools.
	BuildToolGo BuildToolType = iota
	// BuildToolRust represents Rust/Cargo build tools.
	BuildToolRust
	// BuildToolNode represents Node.js build tools.
	BuildToolNode
	// BuildToolPython represents Python build tools.
	BuildToolPython
	// BuildToolJava represents Java build tools (Maven, Gradle).
	BuildToolJava
	// BuildToolScala represents Scala build tools (SBT).
	BuildToolScala
)

func (BuildToolType) IsValid

func (bt BuildToolType) IsValid() bool

func (BuildToolType) MarshalYAML

func (bt BuildToolType) MarshalYAML() (any, error)

func (BuildToolType) String

func (bt BuildToolType) String() string

func (*BuildToolType) UnmarshalYAML

func (bt *BuildToolType) UnmarshalYAML(value *yaml.Node) error

func (BuildToolType) Values

func (bt BuildToolType) Values() []BuildToolType

type CacheCleanupMode

type CacheCleanupMode int

CacheCleanupMode represents cache cleanup behavior as a type-safe enum.

const (
	// CacheCleanupDisabled represents disabled cache cleanup.
	CacheCleanupDisabled CacheCleanupMode = iota
	// CacheCleanupEnabled represents enabled cache cleanup.
	CacheCleanupEnabled
)

func (CacheCleanupMode) IsEnabled

func (cm CacheCleanupMode) IsEnabled() bool

func (CacheCleanupMode) IsValid

func (cm CacheCleanupMode) IsValid() bool

func (CacheCleanupMode) MarshalYAML

func (cm CacheCleanupMode) MarshalYAML() (any, error)

func (CacheCleanupMode) String

func (cm CacheCleanupMode) String() string

func (*CacheCleanupMode) UnmarshalYAML

func (cm *CacheCleanupMode) UnmarshalYAML(value *yaml.Node) error

func (CacheCleanupMode) Values

func (cm CacheCleanupMode) Values() []CacheCleanupMode

type CacheType

type CacheType int

CacheType represents system cache types as a type-safe enum.

const (
	// CacheTypeSpotlight represents macOS Spotlight cache.
	CacheTypeSpotlight CacheType = iota
	// CacheTypeXcode represents Xcode derived data cache.
	CacheTypeXcode
	// CacheTypeCocoapods represents CocoaPods cache.
	CacheTypeCocoapods
	// CacheTypeHomebrew represents Homebrew cache.
	CacheTypeHomebrew
	// CacheTypePip represents Python pip cache.
	CacheTypePip
	// CacheTypeNpm represents Node.js npm cache.
	CacheTypeNpm
	// CacheTypeYarn represents Yarn cache.
	CacheTypeYarn
	// CacheTypeCcache represents ccache.
	CacheTypeCcache
	// CacheTypeXdgCache represents Linux XDG cache directory (~/.cache).
	CacheTypeXdgCache
	// CacheTypeThumbnails represents Linux thumbnail cache.
	CacheTypeThumbnails
	// CacheTypePuppeteer represents Puppeteer browser cache.
	CacheTypePuppeteer
	// CacheTypeTerraform represents Terraform plugin cache.
	CacheTypeTerraform
	// CacheTypeGradleWrapper represents Gradle wrapper distributions cache.
	CacheTypeGradleWrapper
	// CacheTypeKonan represents Kotlin/Native toolchain dependencies.
	CacheTypeKonan
	// CacheTypeRustup represents Rust toolchain cache.
	CacheTypeRustup
)

func (CacheType) IsValid

func (ct CacheType) IsValid() bool

func (CacheType) MarshalYAML

func (ct CacheType) MarshalYAML() (any, error)

func (CacheType) String

func (ct CacheType) String() string

func (*CacheType) UnmarshalYAML

func (ct *CacheType) UnmarshalYAML(value *yaml.Node) error

func (CacheType) Values

func (ct CacheType) Values() []CacheType

type CargoPackagesSettings

type CargoPackagesSettings struct {
	Autoclean CacheCleanupMode `json:"autoclean,omitempty" yaml:"autoclean,omitempty"`
}

CargoPackagesSettings provides type-safe settings for Cargo package manager cleanup.

type ChangeOperationType

type ChangeOperationType int

ChangeOperationType represents change operations with compile-time safety.

const (
	ChangeOperationAddedType ChangeOperationType = iota
	ChangeOperationRemovedType
	ChangeOperationModifiedType
)

func (ChangeOperationType) IsValid

func (co ChangeOperationType) IsValid() bool

func (ChangeOperationType) MarshalJSON

func (co ChangeOperationType) MarshalJSON() ([]byte, error)

func (ChangeOperationType) String

func (co ChangeOperationType) String() string

func (*ChangeOperationType) UnmarshalJSON

func (co *ChangeOperationType) UnmarshalJSON(data []byte) error

func (ChangeOperationType) Values

type CleanRequest

type CleanRequest struct {
	Items    []ScanItem        `json:"items"`
	Strategy CleanStrategyType `json:"strategy"`
}

CleanRequest represents cleaning command.

func (CleanRequest) Validate

func (cr CleanRequest) Validate() error

Validate returns errors for invalid clean request.

type CleanResult

type CleanResult struct {
	SizeEstimate SizeEstimate      `json:"size_estimate"`
	FreedBytes   uint64            `json:"freed_bytes"` // Deprecated: Use SizeEstimate instead
	ItemsRemoved uint              `json:"items_removed"`
	ItemsFailed  uint              `json:"items_failed"`
	CleanTime    time.Duration     `json:"clean_time"`
	CleanedAt    time.Time         `json:"cleaned_at"`
	Strategy     CleanStrategyType `json:"strategy"`
}

CleanResult represents successful clean outcome.

func (CleanResult) IsValid

func (cr CleanResult) IsValid() bool

IsValid checks if clean result is valid.

func (CleanResult) Validate

func (cr CleanResult) Validate() error

Validate returns errors for invalid clean result.

type CleanStrategyType

type CleanStrategyType int

CleanStrategyType represents cleaning strategies with compile-time safety.

const (
	StrategyAggressiveType CleanStrategyType = iota
	StrategyConservativeType
	StrategyDryRunType
)

func (CleanStrategyType) Icon

func (cs CleanStrategyType) Icon() string

func (CleanStrategyType) IsValid

func (cs CleanStrategyType) IsValid() bool

func (CleanStrategyType) MarshalJSON

func (cs CleanStrategyType) MarshalJSON() ([]byte, error)

func (CleanStrategyType) String

func (cs CleanStrategyType) String() string

func (*CleanStrategyType) UnmarshalJSON

func (cs *CleanStrategyType) UnmarshalJSON(data []byte) error

func (CleanStrategyType) Values

func (cs CleanStrategyType) Values() []CleanStrategyType

type CleanupOperation

type CleanupOperation struct {
	Name        string             `json:"name"               yaml:"name"`
	Description string             `json:"description"        yaml:"description"`
	RiskLevel   RiskLevelType      `json:"risk_level"         yaml:"risk_level"`
	Enabled     ProfileStatus      `json:"enabled"            yaml:"enabled"`
	Settings    *OperationSettings `json:"settings,omitempty" yaml:"settings,omitempty"`
}

CleanupOperation represents single cleanup operation with type-safe settings.

func (CleanupOperation) IsValid

func (op CleanupOperation) IsValid() bool

IsValid validates cleanup operation.

func (CleanupOperation) Validate

func (op CleanupOperation) Validate() error

Validate returns errors for invalid cleanup operation.

type CompiledBinariesSettings

type CompiledBinariesSettings struct {
	// MinSizeMB minimum file size in MB to consider (default: 10)
	MinSizeMB int `json:"min_size_mb,omitempty" yaml:"min_size_mb,omitempty"`
	// OlderThan age filter for files (default: "0" = any age)
	OlderThan string `json:"older_than,omitempty" yaml:"older_than,omitempty"`
	// BasePaths directories to scan (default: ~/projects or user home)
	BasePaths []string `json:"base_paths,omitempty" yaml:"base_paths,omitempty"`
	// ExcludePatterns glob patterns to exclude
	ExcludePatterns []string `json:"exclude_patterns,omitempty" yaml:"exclude_patterns,omitempty"`
	// IncludePatterns categories to include: tmp, test, bin, dist, root
	IncludePatterns []string `json:"include_patterns,omitempty" yaml:"include_patterns,omitempty"`
}

CompiledBinariesSettings provides type-safe settings for compiled binaries cleanup. This cleaner removes large executable files that can be regenerated (build outputs, test binaries).

type Config

type Config struct {
	Version        string              `json:"version"                   yaml:"version"`
	SafeMode       SafeMode            `json:"safe_mode"                 yaml:"safe_mode"`
	MaxDiskUsage   int                 `json:"max_disk_usage"            yaml:"max_disk_usage"`
	Protected      []string            `json:"protected"                 yaml:"protected"`
	Profiles       map[string]*Profile `json:"profiles"                  yaml:"profiles"`
	CurrentProfile string              `json:"current_profile,omitempty" yaml:"current_profile,omitempty"`
	LastClean      time.Time           `json:"last_clean"                yaml:"last_clean"`
	Updated        time.Time           `json:"updated"                   yaml:"updated"`
}

Config represents application configuration with type safety.

func (*Config) IsValid

func (c *Config) IsValid() bool

IsValid validates configuration.

func (*Config) Validate

func (c *Config) Validate() error

Validate returns errors for invalid configuration.

type DockerPruneMode

type DockerPruneMode int

DockerPruneMode represents Docker prune behavior as a type-safe enum.

const (
	// DockerPruneAll represents pruning all resources.
	DockerPruneAll DockerPruneMode = iota
	// DockerPruneImages represents pruning only images.
	DockerPruneImages
	// DockerPruneContainers represents pruning only containers.
	DockerPruneContainers
	// DockerPruneVolumes represents pruning only volumes.
	DockerPruneVolumes
	// DockerPruneBuilds represents pruning only build cache.
	DockerPruneBuilds
)

func (DockerPruneMode) IsValid

func (pm DockerPruneMode) IsValid() bool

func (DockerPruneMode) MarshalYAML

func (pm DockerPruneMode) MarshalYAML() (any, error)

func (DockerPruneMode) String

func (pm DockerPruneMode) String() string

func (*DockerPruneMode) UnmarshalYAML

func (pm *DockerPruneMode) UnmarshalYAML(value *yaml.Node) error

func (DockerPruneMode) Values

func (pm DockerPruneMode) Values() []DockerPruneMode

type DockerResourceID

type DockerResourceID string

DockerResourceID is a strong ID type for Docker resource identifiers.

type DockerSettings

type DockerSettings struct {
	PruneMode DockerPruneMode `json:"prune_mode,omitempty" yaml:"prune_mode,omitempty"`
}

DockerSettings provides type-safe settings for Docker cleanup.

type ExecutionMode

type ExecutionMode int
const (
	ExecutionModeDryRun ExecutionMode = iota
	ExecutionModeNormal
	ExecutionModeForce
)

func (ExecutionMode) IsDryRun

func (em ExecutionMode) IsDryRun() bool

func (ExecutionMode) IsForce

func (em ExecutionMode) IsForce() bool

func (ExecutionMode) IsValid

func (em ExecutionMode) IsValid() bool

func (ExecutionMode) MarshalYAML

func (em ExecutionMode) MarshalYAML() (any, error)

func (ExecutionMode) String

func (em ExecutionMode) String() string

func (*ExecutionMode) UnmarshalYAML

func (em *ExecutionMode) UnmarshalYAML(value *yaml.Node) error

func (ExecutionMode) Values

func (em ExecutionMode) Values() []ExecutionMode

type GenerationCleaner

type GenerationCleaner interface {
	OperationHandler
	ListGenerations(ctx context.Context) []NixGeneration
	CleanOldGenerations(ctx context.Context, keepCount int) CleanResult
}

GenerationCleaner is an OperationHandler interface for generation-based cleaners (Nix).

type GenerationStatus

type GenerationStatus int
const (
	GenerationStatusHistorical GenerationStatus = iota
	GenerationStatusCurrent
)

func (GenerationStatus) IsCurrent

func (gs GenerationStatus) IsCurrent() bool

func (GenerationStatus) IsValid

func (gs GenerationStatus) IsValid() bool

func (GenerationStatus) String

func (gs GenerationStatus) String() string

func (GenerationStatus) Values

func (gs GenerationStatus) Values() []GenerationStatus

type GitHistoryFile

type GitHistoryFile struct {
	// Path is the file path in the repository
	Path string `json:"path"`
	// SizeBytes is the file size in bytes
	SizeBytes int64 `json:"size_bytes"`
	// BlobHash is the git blob hash
	BlobHash string `json:"blob_hash"`
	// CommitHash is the commit that added this file
	CommitHash string `json:"commit_hash"`
	// CommitDate is when the commit was made
	CommitDate time.Time `json:"commit_date"`
	// Author is who committed the file
	Author string `json:"author"`
	// IsDeleted indicates if the file exists in HEAD
	IsDeleted bool `json:"is_deleted"`
	// Extension is the file extension (empty for extensionless binaries)
	Extension string `json:"extension"`
	// Selected indicates if this file is selected for removal (for TUI)
	Selected bool `json:"selected,omitempty"`
}

GitHistoryFile represents a binary file found in git history.

func (GitHistoryFile) IsValid

func (f GitHistoryFile) IsValid() bool

IsValid validates the GitHistoryFile.

func (GitHistoryFile) SizeMB

func (f GitHistoryFile) SizeMB() float64

SizeMB returns the file size in megabytes.

func (GitHistoryFile) Validate

func (f GitHistoryFile) Validate() error

Validate returns errors for invalid GitHistoryFile.

type GitHistoryMode

type GitHistoryMode int

GitHistoryMode represents the mode of operation for git history cleaning.

const (
	GitHistoryModeAnalyze GitHistoryMode = iota // Only report findings
	GitHistoryModeDryRun                        // Show what would be done
	GitHistoryModeExecute                       // Actually rewrite history
)

func (GitHistoryMode) IsValid

func (m GitHistoryMode) IsValid() bool

func (GitHistoryMode) MarshalJSON

func (m GitHistoryMode) MarshalJSON() ([]byte, error)

func (GitHistoryMode) String

func (m GitHistoryMode) String() string

func (*GitHistoryMode) UnmarshalJSON

func (m *GitHistoryMode) UnmarshalJSON(data []byte) error

func (GitHistoryMode) Values

func (m GitHistoryMode) Values() []GitHistoryMode

type GitHistoryRewriteResult

type GitHistoryRewriteResult struct {
	// FilesRemoved is the list of files that were removed
	FilesRemoved []GitHistoryFile `json:"files_removed"`
	// BytesRemoved is the total bytes removed
	BytesRemoved int64 `json:"bytes_removed"`
	// CommitsAffected is the number of commits that were modified
	CommitsAffected int `json:"commits_affected"`
	// OldRepoSize is the repository size before rewrite
	OldRepoSize int64 `json:"old_repo_size"`
	// NewRepoSize is the repository size after rewrite
	NewRepoSize int64 `json:"new_repo_size"`
	// BytesReclaimed is the actual space reclaimed
	BytesReclaimed int64 `json:"bytes_reclaimed"`
	// BackupCreated indicates if a backup was made
	BackupCreated bool `json:"backup_created"`
	// BackupPath is the path to the backup
	BackupPath string `json:"backup_path,omitempty"`
	// ExecutedAt is when the rewrite was performed
	ExecutedAt time.Time `json:"executed_at"`
	// Duration is how long the rewrite took
	Duration time.Duration `json:"duration"`
}

GitHistoryRewriteResult contains the results of rewriting git history.

func (GitHistoryRewriteResult) IsValid

func (r GitHistoryRewriteResult) IsValid() bool

IsValid validates the GitHistoryRewriteResult.

type GitHistorySafetyReport

type GitHistorySafetyReport struct {
	// IsGitRepo indicates if the path is a git repository
	IsGitRepo bool `json:"is_git_repo"`
	// HasUncommittedChanges indicates if there are uncommitted changes
	HasUncommittedChanges bool `json:"has_uncommitted_changes"`
	// HasRemote indicates if the repo has a remote
	HasRemote bool `json:"has_remote"`
	// RemoteURL is the remote URL (if any)
	RemoteURL string `json:"remote_url,omitempty"`
	// RemoteName is the remote name (usually "origin")
	RemoteName string `json:"remote_name,omitempty"`
	// CurrentBranch is the current branch name
	CurrentBranch string `json:"current_branch"`
	// HasUnpushedCommits indicates if there are unpushed commits
	HasUnpushedCommits bool `json:"has_unpushed_commits"`
	// CanCreateBackup indicates if a backup can be created
	CanCreateBackup bool `json:"can_create_backup"`
	// DefaultBackupPath is the suggested backup path
	DefaultBackupPath string `json:"default_backup_path,omitempty"`
	// FilterRepoAvailable indicates if git-filter-repo is installed
	FilterRepoAvailable bool `json:"filter_repo_available"`
	// FilterRepoProvider indicates how git-filter-repo is available ("system", "nix", or "")
	FilterRepoProvider string `json:"filter_repo_provider,omitempty"`
	// HasLFS indicates if Git LFS is configured for this repository
	HasLFS bool `json:"has_lfs"`
	// HasSubmodules indicates if the repository contains submodules
	HasSubmodules bool `json:"has_submodules"`
	// IsProtectedBranch indicates if current branch is a protected branch (main, master, production)
	IsProtectedBranch bool `json:"is_protected_branch"`
	// HasSufficientDiskSpace indicates if there's enough disk space for backup
	HasSufficientDiskSpace bool `json:"has_sufficient_disk_space"`
	// Warnings are non-blocking issues
	Warnings []string `json:"warnings,omitempty"`
	// Blockers are issues that must be resolved before proceeding
	Blockers []string `json:"blockers,omitempty"`
}

GitHistorySafetyReport contains safety check results.

func (GitHistorySafetyReport) CanProceed

func (r GitHistorySafetyReport) CanProceed() bool

CanProceed returns true if there are no blockers.

type GitHistoryScanResult

type GitHistoryScanResult struct {
	// Files is the list of binary files found
	Files []GitHistoryFile `json:"files"`
	// TotalBytes is the total size of all files
	TotalBytes int64 `json:"total_bytes"`
	// TotalFiles is the count of files found
	TotalFiles int `json:"total_files"`
	// RepoPath is the path to the repository
	RepoPath string `json:"repo_path"`
	// ScannedAt is when the scan was performed
	ScannedAt time.Time `json:"scanned_at"`
	// Duration is how long the scan took
	Duration time.Duration `json:"duration"`
}

GitHistoryScanResult contains the results of scanning git history.

func (GitHistoryScanResult) IsValid

func (r GitHistoryScanResult) IsValid() bool

IsValid validates the GitHistoryScanResult.

type GitHistorySettings

type GitHistorySettings struct {
	// MinSizeMB is the minimum file size in MB to consider (default: 1)
	MinSizeMB int `json:"min_size_mb,omitempty" yaml:"min_size_mb,omitempty"`
	// MaxFiles limits the number of files to show (0 = unlimited)
	MaxFiles int `json:"max_files,omitempty" yaml:"max_files,omitempty"`
	// ExcludeExtensions are file extensions to exclude
	ExcludeExtensions []string `json:"exclude_extensions,omitempty" yaml:"exclude_extensions,omitempty"`
	// IncludeExtensions are file extensions to include (empty = all)
	IncludeExtensions []string `json:"include_extensions,omitempty" yaml:"include_extensions,omitempty"`
	// ExcludePaths are path patterns to exclude
	ExcludePaths []string `json:"exclude_paths,omitempty" yaml:"exclude_paths,omitempty"`
	// CreateBackup indicates if a backup should be created before rewrite
	CreateBackup bool `json:"create_backup,omitempty" yaml:"create_backup,omitempty"`
	// SkipConfirmation skips the interactive confirmation (dangerous)
	SkipConfirmation bool `json:"skip_confirmation,omitempty" yaml:"skip_confirmation,omitempty"`
}

GitHistorySettings provides type-safe settings for git history cleaning.

func DefaultGitHistorySettings

func DefaultGitHistorySettings() GitHistorySettings

DefaultGitHistorySettings returns the default settings.

type GoPackagesSettings

type GoPackagesSettings struct {
	CleanCache      CacheCleanupMode `json:"clean_cache,omitempty"       yaml:"clean_cache,omitempty"`
	CleanTestCache  CacheCleanupMode `json:"clean_test_cache,omitempty"  yaml:"clean_test_cache,omitempty"`
	CleanModCache   CacheCleanupMode `json:"clean_mod_cache,omitempty"   yaml:"clean_mod_cache,omitempty"`
	CleanBuildCache CacheCleanupMode `json:"clean_build_cache,omitempty" yaml:"clean_build_cache,omitempty"`
	CleanLintCache  CacheCleanupMode `json:"clean_lint_cache,omitempty"  yaml:"clean_lint_cache,omitempty"`
}

GoPackagesSettings provides type-safe settings for Go language cleanup.

type HomebrewMode

type HomebrewMode int
const (
	HomebrewModeAll HomebrewMode = iota
	HomebrewModeUnusedOnly
)

func (HomebrewMode) IsUnusedOnly

func (hm HomebrewMode) IsUnusedOnly() bool

func (HomebrewMode) IsValid

func (hm HomebrewMode) IsValid() bool

func (HomebrewMode) MarshalYAML

func (hm HomebrewMode) MarshalYAML() (any, error)

func (HomebrewMode) String

func (hm HomebrewMode) String() string

func (*HomebrewMode) UnmarshalYAML

func (hm *HomebrewMode) UnmarshalYAML(value *yaml.Node) error

func (HomebrewMode) Values

func (hm HomebrewMode) Values() []HomebrewMode

type HomebrewSettings

type HomebrewSettings struct {
	UnusedOnly HomebrewMode `json:"unused_only"     yaml:"unused_only"`
	Prune      string       `json:"prune,omitempty" yaml:"prune,omitempty"`
}

HomebrewSettings provides type-safe settings for Homebrew cleanup.

type NixGeneration

type NixGeneration struct {
	ID      NixGenerationID  `json:"id"`
	Path    string           `json:"path"`
	Date    time.Time        `json:"date"`
	Current GenerationStatus `json:"current"`
}

NixGeneration represents Nix store generation.

func (NixGeneration) EstimateSize

func (g NixGeneration) EstimateSize() int64

EstimateSize estimates the size of this generation in bytes This is a rough estimate used when actual size calculation is not available.

func (NixGeneration) IsValid

func (g NixGeneration) IsValid() bool

IsValid validates generation.

func (NixGeneration) Validate

func (g NixGeneration) Validate() error

Validate returns errors for invalid generation.

type NixGenerationID

type NixGenerationID int

NixGenerationID is a strong ID type for Nix generation identifiers.

type NixGenerationsSettings

type NixGenerationsSettings struct {
	Generations int              `json:"generations"       yaml:"generations"`
	Optimize    OptimizationMode `json:"optimize"          yaml:"optimize"`
	DryRun      ExecutionMode    `json:"dry_run,omitempty" yaml:"dry_run,omitempty"`
}

NixGenerationsSettings provides type-safe settings for Nix generations cleanup.

type NodePackagesSettings

type NodePackagesSettings struct {
	PackageManagers []PackageManagerType `json:"package_managers" yaml:"package_managers"`
}

NodePackagesSettings provides type-safe settings for Node.js package manager cleanup.

type OperationHandler

type OperationHandler interface {
	Type() OperationType
	IsAvailable(ctx context.Context) bool
	GetStoreSize(ctx context.Context) int64
	ValidateSettings(settings *OperationSettings) error
}

OperationHandler interface for all cleaning operations with type-safe settings.

type OperationSettings

type OperationSettings struct {
	// Nix Generations Settings
	NixGenerations *NixGenerationsSettings `json:"nix_generations,omitempty" yaml:"nix_generations,omitempty"`

	// Temp Files Settings
	TempFiles *TempFilesSettings `json:"temp_files,omitempty" yaml:"temp_files,omitempty"`

	// Homebrew Settings
	Homebrew *HomebrewSettings `json:"homebrew,omitempty" yaml:"homebrew,omitempty"`

	// Node Packages Settings
	NodePackages *NodePackagesSettings `json:"node_packages,omitempty" yaml:"node_packages,omitempty"`

	// Go Packages Settings
	GoPackages *GoPackagesSettings `json:"go_packages,omitempty" yaml:"go_packages,omitempty"`

	// Cargo Packages Settings
	CargoPackages *CargoPackagesSettings `json:"cargo_packages,omitempty" yaml:"cargo_packages,omitempty"`

	// Build Cache Settings
	BuildCache *BuildCacheSettings `json:"build_cache,omitempty" yaml:"build_cache,omitempty"`

	// Docker Settings
	Docker *DockerSettings `json:"docker,omitempty" yaml:"docker,omitempty"`

	// System Cache Settings
	SystemCache *SystemCacheSettings `json:"system_cache,omitempty" yaml:"system_cache,omitempty"`

	// System Temp Settings
	SystemTemp *SystemTempSettings `json:"system_temp,omitempty" yaml:"system_temp,omitempty"`

	// Projects Management Automation Settings
	ProjectsManagementAutomation *ProjectsManagementAutomationSettings `json:"projects_management_automation,omitempty"`
	// Project Executables Settings
	ProjectExecutables *ProjectExecutablesSettings `json:"project_executables,omitempty"`

	// Compiled Binaries Settings
	CompiledBinaries *CompiledBinariesSettings `json:"compiled_binaries,omitempty" yaml:"compiled_binaries,omitempty"`

	// Git History Settings
	GitHistory *GitHistorySettings `json:"git_history,omitempty" yaml:"git_history,omitempty"`
}

OperationSettings provides type-safe configuration for different operation types This eliminates map[string]any violations while maintaining flexibility.

func DefaultSettings

func DefaultSettings(opType OperationType) *OperationSettings

DefaultSettings returns default settings for given operation type.

func (*OperationSettings) ValidateSettings

func (os *OperationSettings) ValidateSettings(opType OperationType) error

ValidateSettings validates settings for the given operation type.

type OperationType

type OperationType string

OperationType represents different types of cleanup operations.

const (
	OperationTypeNixGenerations               OperationType = "nix-generations"
	OperationTypeTempFiles                    OperationType = "temp-files"
	OperationTypeHomebrew                     OperationType = "homebrew-cleanup"
	OperationTypeNodePackages                 OperationType = "node-packages"
	OperationTypeGoPackages                   OperationType = "go-packages"
	OperationTypeCargoPackages                OperationType = "cargo-packages"
	OperationTypeBuildCache                   OperationType = "build-cache"
	OperationTypeDocker                       OperationType = "docker"
	OperationTypeSystemCache                  OperationType = "system-cache"
	OperationTypeSystemTemp                   OperationType = "system-temp"
	OperationTypeProjectsManagementAutomation OperationType = "projects-management-automation"
	OperationTypeProjectExecutables           OperationType = "project-executables"
	OperationTypeCompiledBinaries             OperationType = "compiled-binaries"
	OperationTypeGitHistory                   OperationType = "git-history"
	OperationTypeGolangciLintCache            OperationType = "golangci-lint-cache"
)

func GetOperationType

func GetOperationType(name string) OperationType

GetOperationType returns the operation type from operation name.

func (OperationType) IsValid

func (ot OperationType) IsValid() bool

IsValid returns true if the OperationType is a known valid type.

func (OperationType) String

func (ot OperationType) String() string

String returns the string representation of the OperationType.

func (OperationType) Values

func (OperationType) Values() []OperationType

Values returns all valid OperationType values.

type OptimizationMode

type OptimizationMode int
const (
	OptimizationModeDisabled OptimizationMode = iota
	OptimizationModeEnabled
)

func (OptimizationMode) IsEnabled

func (om OptimizationMode) IsEnabled() bool

func (OptimizationMode) IsValid

func (om OptimizationMode) IsValid() bool

func (OptimizationMode) MarshalYAML

func (om OptimizationMode) MarshalYAML() (any, error)

func (OptimizationMode) String

func (om OptimizationMode) String() string

func (*OptimizationMode) UnmarshalYAML

func (om *OptimizationMode) UnmarshalYAML(value *yaml.Node) error

func (OptimizationMode) Values

func (om OptimizationMode) Values() []OptimizationMode

type PackageCleaner

type PackageCleaner interface {
	OperationHandler
	ListPackages(ctx context.Context) []string
	CleanOldPackages(ctx context.Context, settings *OperationSettings) CleanResult
}

PackageCleaner is an OperationHandler interface for package-based cleaners (Homebrew).

type PackageManagerType

type PackageManagerType int

PackageManagerType represents Node.js package manager types as a type-safe enum.

const (
	// PackageManagerNpm represents npm.
	PackageManagerNpm PackageManagerType = iota
	// PackageManagerPnpm represents pnpm.
	PackageManagerPnpm
	// PackageManagerYarn represents Yarn.
	PackageManagerYarn
	// PackageManagerBun represents Bun.
	PackageManagerBun
)

func (PackageManagerType) IsValid

func (pm PackageManagerType) IsValid() bool

func (PackageManagerType) MarshalYAML

func (pm PackageManagerType) MarshalYAML() (any, error)

func (PackageManagerType) String

func (pm PackageManagerType) String() string

func (*PackageManagerType) UnmarshalYAML

func (pm *PackageManagerType) UnmarshalYAML(value *yaml.Node) error

func (PackageManagerType) Values

func (pm PackageManagerType) Values() []PackageManagerType

type Profile

type Profile struct {
	Name        string             `json:"name"        yaml:"name"`
	Description string             `json:"description" yaml:"description"`
	Operations  []CleanupOperation `json:"operations"  yaml:"operations"`
	Enabled     ProfileStatus      `json:"enabled"     yaml:"enabled"`
}

Profile represents cleanup profile.

func (*Profile) IsValid

func (p *Profile) IsValid(name string) bool

IsValid validates profile.

func (*Profile) Validate

func (p *Profile) Validate(name string) error

Validate returns errors for invalid profile.

type ProfileStatus

type ProfileStatus int
const (
	ProfileStatusDisabled ProfileStatus = iota
	ProfileStatusEnabled
)

func (ProfileStatus) IsEnabled

func (ps ProfileStatus) IsEnabled() bool

func (ProfileStatus) IsValid

func (ps ProfileStatus) IsValid() bool

func (ProfileStatus) MarshalYAML

func (ps ProfileStatus) MarshalYAML() (any, error)

func (ProfileStatus) String

func (ps ProfileStatus) String() string

func (*ProfileStatus) UnmarshalYAML

func (ps *ProfileStatus) UnmarshalYAML(value *yaml.Node) error

func (ProfileStatus) Values

func (ps ProfileStatus) Values() []ProfileStatus

type ProjectExecutablesSettings

type ProjectExecutablesSettings struct {
	// ExcludeExtensions specifies file extensions to exclude from cleanup (default: ".sh")
	ExcludeExtensions []string `json:"exclude_extensions,omitempty" yaml:"exclude_extensions,omitempty"`
	// ExcludePatterns specifies glob patterns to exclude from cleanup
	ExcludePatterns []string `json:"exclude_patterns,omitempty" yaml:"exclude_patterns,omitempty"`
}

ProjectExecutablesSettings provides type-safe settings for project executables cleanup. This cleaner removes executable files (not shell scripts) from project root directories.

type ProjectsManagementAutomationSettings

type ProjectsManagementAutomationSettings struct {
	ClearCache CacheCleanupMode `json:"clear_cache" yaml:"clear_cache"`
}

ProjectsManagementAutomationSettings provides type-safe settings for projects management automation cleanup.

type RiskLevelType

type RiskLevelType int

RiskLevelType represents the risk level enum with compile-time safety.

const (
	RiskLevelLowType RiskLevelType = iota
	RiskLevelMediumType
	RiskLevelHighType
	RiskLevelCriticalType
)

func (RiskLevelType) Icon

func (rl RiskLevelType) Icon() string

func (RiskLevelType) IsHigherOrEqualThan

func (rl RiskLevelType) IsHigherOrEqualThan(other RiskLevelType) bool

func (RiskLevelType) IsHigherThan

func (rl RiskLevelType) IsHigherThan(other RiskLevelType) bool

func (RiskLevelType) IsValid

func (rl RiskLevelType) IsValid() bool

func (RiskLevelType) MarshalJSON

func (rl RiskLevelType) MarshalJSON() ([]byte, error)

func (RiskLevelType) MarshalYAML

func (rl RiskLevelType) MarshalYAML() (any, error)

func (RiskLevelType) String

func (rl RiskLevelType) String() string

func (*RiskLevelType) UnmarshalJSON

func (rl *RiskLevelType) UnmarshalJSON(data []byte) error

func (*RiskLevelType) UnmarshalYAML

func (rl *RiskLevelType) UnmarshalYAML(value *yaml.Node) error

func (RiskLevelType) Values

func (rl RiskLevelType) Values() []RiskLevelType

type SafeMode

type SafeMode int
const (
	SafeModeDisabled SafeMode = iota
	SafeModeEnabled
	SafeModeStrict
)

func (SafeMode) IsEnabled

func (sm SafeMode) IsEnabled() bool

func (SafeMode) IsStrict

func (sm SafeMode) IsStrict() bool

func (SafeMode) IsValid

func (sm SafeMode) IsValid() bool

func (SafeMode) MarshalYAML

func (sm SafeMode) MarshalYAML() (any, error)

func (SafeMode) String

func (sm SafeMode) String() string

func (*SafeMode) UnmarshalYAML

func (sm *SafeMode) UnmarshalYAML(value *yaml.Node) error

func (SafeMode) Values

func (sm SafeMode) Values() []SafeMode

type SanitizationWarning

type SanitizationWarning struct {
	Field     string `json:"field"`
	Message   string `json:"message,omitempty"`
	Original  any    `json:"original,omitempty"`
	Sanitized any    `json:"sanitized,omitempty"`
	OldValue  any    `json:"old_value,omitempty"`
	NewValue  any    `json:"new_value,omitempty"`
	Reason    string `json:"reason,omitempty"`
}

SanitizationWarning represents a warning during sanitization.

type ScanItem

type ScanItem struct {
	Path     string    `json:"path"`
	Size     int64     `json:"size"`
	Created  time.Time `json:"created"`
	ScanType ScanType  `json:"scan_type"`
}

ScanItem represents item found during scanning.

type ScanMode

type ScanMode int
const (
	ScanModeNonRecursive ScanMode = iota
	ScanModeRecursive
)

func (ScanMode) IsRecursive

func (sm ScanMode) IsRecursive() bool

func (ScanMode) IsValid

func (sm ScanMode) IsValid() bool

func (ScanMode) String

func (sm ScanMode) String() string

func (ScanMode) Values

func (sm ScanMode) Values() []ScanMode

type ScanRequest

type ScanRequest struct {
	Type      ScanType `json:"type"`
	Recursive ScanMode `json:"recursive"`
	Limit     int      `json:"limit"`
}

ScanRequest represents scanning command.

func (ScanRequest) Validate

func (sr ScanRequest) Validate() error

Validate returns errors for invalid scan request.

type ScanResult

type ScanResult struct {
	TotalBytes   int64         `json:"total_bytes"`
	TotalItems   int           `json:"total_items"`
	ScannedPaths []string      `json:"scanned_paths"`
	ScanTime     time.Duration `json:"scan_time"`
	ScannedAt    time.Time     `json:"scanned_at"`
}

ScanResult represents successful scan outcome.

func (ScanResult) IsValid

func (sr ScanResult) IsValid() bool

IsValid checks if scan result is valid.

func (ScanResult) Validate

func (sr ScanResult) Validate() error

Validate returns errors for invalid scan result.

type ScanType

type ScanType string

ScanType represents different scanning domains.

const (
	ScanTypeNixStore ScanType = "nix_store"
	ScanTypeHomebrew ScanType = "homebrew"
	ScanTypeSystem   ScanType = "system"
	ScanTypeTemp     ScanType = "temp_files"
	ScanTypeCache    ScanType = "cache"
)

func (ScanType) IsValid

func (st ScanType) IsValid() bool

IsValid validates ScanType.

func (ScanType) String

func (st ScanType) String() string

String returns string representation of scan type.

func (ScanType) Values

func (st ScanType) Values() []ScanType

Values returns all possible scan types.

type Scanner

type Scanner interface {
	Scan(ctx context.Context, req ScanRequest) ScanResult
}

Scanner interface for all scanning operations.

type SizeEstimate

type SizeEstimate struct {
	Known  uint64                 `json:"known"`
	Status SizeEstimateStatusType `json:"status"`
}

SizeEstimate represents an honest size estimate, handling cases where exact size is unknown.

func (SizeEstimate) IsKnown

func (se SizeEstimate) IsKnown() bool

IsKnown returns true if the size is known.

func (SizeEstimate) String

func (se SizeEstimate) String() string

String returns a formatted string representation.

func (SizeEstimate) Value

func (se SizeEstimate) Value() uint64

Value returns the known value, or 0 if unknown.

type SizeEstimateStatusType

type SizeEstimateStatusType int

SizeEstimateStatusType represents the status of a size estimate with type safety. This replaces the boolean Unknown field, making impossible states unrepresentable.

const (
	// SizeEstimateStatusKnown represents a known/calculated size.
	SizeEstimateStatusKnown SizeEstimateStatusType = iota
	// SizeEstimateStatusUnknown represents an unknown/estimated size.
	SizeEstimateStatusUnknown
)

func (SizeEstimateStatusType) IsValid

func (ses SizeEstimateStatusType) IsValid() bool

func (SizeEstimateStatusType) MarshalJSON

func (ses SizeEstimateStatusType) MarshalJSON() ([]byte, error)

func (SizeEstimateStatusType) String

func (ses SizeEstimateStatusType) String() string

func (*SizeEstimateStatusType) UnmarshalJSON

func (ses *SizeEstimateStatusType) UnmarshalJSON(data []byte) error

func (SizeEstimateStatusType) Values

type SystemCacheSettings

type SystemCacheSettings struct {
	CacheTypes []CacheType `json:"cache_types,omitempty" yaml:"cache_types,omitempty"`
	OlderThan  string      `json:"older_than,omitempty"  yaml:"older_than,omitempty"`
}

SystemCacheSettings provides type-safe settings for macOS system cache cleanup.

type SystemTempSettings

type SystemTempSettings struct {
	Paths     []string `json:"paths"      yaml:"paths"`
	OlderThan string   `json:"older_than" yaml:"older_than"`
}

SystemTempSettings provides type-safe settings for system temp cleanup.

type TempFilesSettings

type TempFilesSettings struct {
	OlderThan string   `json:"older_than"         yaml:"older_than"`
	Excludes  []string `json:"excludes,omitempty" yaml:"excludes,omitempty"`
}

TempFilesSettings provides type-safe settings for temporary files cleanup.

type ValidationContext

type ValidationContext struct {
	ConfigPath      string            `json:"config_path,omitempty"`
	ValidationLevel string            `json:"validation_level,omitempty"`
	Profile         string            `json:"profile,omitempty"`
	Section         string            `json:"section,omitempty"`
	MinValue        any               `json:"min_value,omitempty"`
	MaxValue        any               `json:"max_value,omitempty"`
	AllowedValues   []string          `json:"allowed_values,omitempty"`
	ReferencedField string            `json:"referenced_field,omitempty"`
	Constraints     map[string]string `json:"constraints,omitempty"`
	Metadata        map[string]string `json:"metadata,omitempty"`
}

ValidationContext provides strongly-typed validation context information.

type ValidationError

type ValidationError struct {
	Field      string             `json:"field"`
	Rule       string             `json:"rule,omitempty"`
	Value      any                `json:"value"`
	Message    string             `json:"message"`
	Severity   ValidationSeverity `json:"severity,omitempty"`
	Suggestion string             `json:"suggestion,omitempty"`
	Context    *ValidationContext `json:"context,omitempty"`
}

ValidationError represents a validation error with comprehensive context.

func (*ValidationError) Error

func (e *ValidationError) Error() string

type ValidationLevelType

type ValidationLevelType int

ValidationLevelType represents validation levels with compile-time safety.

const (
	ValidationLevelNoneType ValidationLevelType = iota
	ValidationLevelBasicType
	ValidationLevelComprehensiveType
	ValidationLevelStrictType
)

func (ValidationLevelType) IsValid

func (vl ValidationLevelType) IsValid() bool

func (ValidationLevelType) MarshalJSON

func (vl ValidationLevelType) MarshalJSON() ([]byte, error)

func (ValidationLevelType) String

func (vl ValidationLevelType) String() string

func (*ValidationLevelType) UnmarshalJSON

func (vl *ValidationLevelType) UnmarshalJSON(data []byte) error

func (ValidationLevelType) Values

type ValidationSeverity

type ValidationSeverity string

ValidationSeverity represents error severity levels.

const (
	SeverityError   ValidationSeverity = "error"
	SeverityWarning ValidationSeverity = "warning"
	SeverityInfo    ValidationSeverity = "info"
)

type ValidationValidID

type ValidationValidID string

ValidationValidID is a strong ID type for validation description identifiers.

Jump to

Keyboard shortcuts

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