Documentation
¶
Index ¶
- Constants
- Variables
- func Bold(msg string, args ...any)
- func Colorize(code, s string) string
- func Error(msg string, args ...any)
- func FormatBytes(b int64) string
- func Info(msg string, args ...any)
- func ProgressBar(pct, width int) string
- func RiskColor(r RiskLevel) string
- func SeverityColor(s Severity) string
- func Success(msg string, args ...any)
- func Warn(msg string, args ...any)
- type AnalysisResult
- type AnalyzeFunc
- type ApprovalEngine
- type ApprovalMode
- type CleanableItem
- type DeleteResult
- type DiskSnapshot
- type RiskLevel
- type RunnerTask
- type Severity
Constants ¶
const ( Reset = colorReset Cyan = colorCyan Gray = colorGray Bold_ = colorBold )
Exported ANSI codes for callers that build their own colored output.
const AnalyzerTimeoutSeconds = 180
AnalyzerTimeoutSeconds bounds each analyzer. Repo scans over large source trees are the slowest domain, so this leaves headroom above their typical runtime while still guarding against a runaway walk.
const DefaultMinSizeMB = 50
DefaultMinSizeMB is the minimum file size (in MB) to flag in downloads
Variables ¶
var ( // HomeDir is the current user's home directory HomeDir string // RepoRoots are directories to scan for node_modules, .venv, __pycache__ RepoRoots []string // BrowserCachePaths maps browser name to its cache directory BrowserCachePaths map[string]string // LogDirs are directories containing log files LogDirs []string // DownloadDirs are directories to scan for large/old downloads DownloadDirs []string // AppSupportDir is ~/Library/Application Support AppSupportDir string // OllamaModelsDir is where Ollama stores downloaded LLM models OllamaModelsDir string // DevCachePaths maps tool name to its cache directory DevCachePaths map[string]string // XcodeDerivedData is the Xcode DerivedData path XcodeDerivedData string // XcodeArchives is the Xcode Archives path XcodeArchives string // XcodeSimulators is the CoreSimulator Devices path XcodeSimulators string // DockerRawPath is the Docker Desktop virtual disk image DockerRawPath string // TrashDir is the user's Trash directory TrashDir string // BlacklistedPaths are app bundle IDs that must never be deleted BlacklistedPaths map[string]bool // BlacklistedPrefixes are path prefixes under which nothing is deleted BlacklistedPrefixes []string )
Functions ¶
func FormatBytes ¶
FormatBytes returns a human-readable byte string (e.g. "1.5 GB")
func ProgressBar ¶ added in v1.2.0
ProgressBar renders a fixed-width unicode bar for a 0..100 percentage, colored green/yellow/red by fill level. width is the number of cells.
func SeverityColor ¶
SeverityColor returns the ANSI color for a severity level
Types ¶
type AnalysisResult ¶
type AnalysisResult struct {
Domain string `json:"domain"`
Severity Severity `json:"severity"`
TotalSize int64 `json:"total_size_bytes"`
Items []CleanableItem `json:"items"`
Summary string `json:"summary"`
Timestamp time.Time `json:"timestamp"`
Error string `json:"error,omitempty"`
}
AnalysisResult holds the result of analyzing one domain
func RunAnalyzers ¶
func RunAnalyzers(tasks []RunnerTask, timeoutSecs int) []AnalysisResult
RunAnalyzers executes all analyzer tasks in parallel with a timeout. Returns results for all domains, including error results for timeouts/failures.
type AnalyzeFunc ¶
type AnalyzeFunc func() (AnalysisResult, error)
AnalyzeFunc is the signature for any analyzer's Analyze method
type ApprovalEngine ¶
type ApprovalEngine struct {
Mode ApprovalMode
DryRun bool
Execute bool
// contains filtered or unexported fields
}
ApprovalEngine handles user approval for cleanup operations
func NewApprovalEngine ¶
func NewApprovalEngine(mode ApprovalMode, dryRun, execute bool) *ApprovalEngine
NewApprovalEngine creates a new approval engine
func (*ApprovalEngine) FilterItems ¶
func (a *ApprovalEngine) FilterItems(results []AnalysisResult) []CleanableItem
FilterItems applies the approval mode to filter items the user wants to delete. Returns only the approved items.
type ApprovalMode ¶
type ApprovalMode string
ApprovalMode defines how the user approves deletions
const ( ApprovalDeal ApprovalMode = "deal" ApprovalCategory ApprovalMode = "category" ApprovalItem ApprovalMode = "item" ApprovalChecklist ApprovalMode = "checklist" )
type CleanableItem ¶
type CleanableItem struct {
Path string `json:"path"`
SizeBytes int64 `json:"size_bytes"`
Label string `json:"label"`
Domain string `json:"domain"`
SafeToDelete bool `json:"safe_to_delete"`
Reason string `json:"reason"`
AgeDays int `json:"age_days,omitempty"`
Risk RiskLevel `json:"risk"`
}
CleanableItem represents a single file or directory that can be cleaned
type DeleteResult ¶
type DeleteResult struct {
Path string `json:"path"`
Result string `json:"result"` // success, skipped-blacklisted, skipped-dry-run, skipped-not-found, failure
SizeBytes int64 `json:"size_bytes,omitempty"`
Error string `json:"error,omitempty"`
}
DeleteResult records what happened when deleting an item
type DiskSnapshot ¶ added in v1.2.0
DiskSnapshot is a lightweight view of the data volume usage, used by the banner and any caller that needs a quick free-space reading without running a full analysis.
func ReadDiskSnapshot ¶ added in v1.2.0
func ReadDiskSnapshot() DiskSnapshot
ReadDiskSnapshot returns current usage of the macOS data volume via `df`. On any parse/exec error it returns a snapshot with OK=false so callers can degrade gracefully instead of failing.
type RunnerTask ¶
type RunnerTask struct {
Domain string
AnalyzeFn AnalyzeFunc
}
RunnerTask pairs a domain name with its analyze function
type Severity ¶
type Severity string
Severity represents analysis severity based on size
func SeverityFromSize ¶
SeverityFromSize returns severity based on total bytes