feat(doctor): add mo doctor command for Mac health diagnostics#659
feat(doctor): add mo doctor command for Mac health diagnostics#659sebastianbreguel wants to merge 10 commits intotw93:mainfrom
Conversation
TUI dashboard (Bubble Tea) that scores system health across 6 categories: - Storage (20pts): free space, recoverable cache, purgeable space - Performance (20pts): RAM pressure (wired+compressed), swap, uptime - Battery (20pts): cycle count, health percentage - Security (20pts): FileVault, Firewall (Sequoia-compatible), SIP, macOS version - Maintenance (15pts): broken launch agents, unused apps, heavy processes - Mole (5pts): version check, config validation, permissions Supports --json for scripted output and --sudo for admin-only checks. Battery points auto-redistribute to other categories on desktop Macs.
6 test files covering all pure-logic functions: - format_test.go: humanizeBytes, progressBar, statusIcon, categoryIcon - scoring_test.go: calculateTotalScore, redistributeBatteryScore, generateTips - json_test.go: statusString - category_battery_test.go: parseIORegInt, checkBatteryCycles, checkBatteryHealth - category_performance_test.go: parseVMStatValue - category_storage_test.go: expandHome
- Storage 15, Performance 20, Battery 15, Security 15, Maintenance 15, Mole 5, Dev Environment 15 - Add hardwareProfile and cacheBreakdownItem types - Rescale battery (8+7), security (4+4+4+3) - Add new threshold constants for v2 checks
- Show all tips instead of only the first one - Add TUI scroll support with viewport and auto-scroll - Add Esc key to quit - Dynamic macOS version check (no longer hardcoded to >= 15) - Context cancellation on quit to stop in-flight goroutines - Extract buildCategory helper to reduce boilerplate across 7 categories - Parallelize checkUnusedApps mdls calls (10x faster) - Expand system process exclusion list (8 daemons) - Fix integer rounding in battery score redistribution - Improve thermal throttling detection patterns - Secure temp file creation in checkMolePermissions (0600 vs 0644) - Add tests for maintenance, mole config, and buildCategory (49 total)
CI runs on Linux where all doctor files have //go:build darwin. Add a main_other.go stub that prints an unsupported message on non-macOS platforms so `make build` succeeds.
- Use min/max builtins instead of if-else patterns (modernize) - Use strings.SplitSeq for efficient iteration (modernize) - Use WaitGroup.Go instead of Add+go+Done (modernize) - Check f.Close() return value (errcheck) - Remove unused diagCtx variable (unused)
Categories now appear one by one during scanning with a spinner, then transition to an interactive collapsed view. Enter to expand individual categories and see check details.
59ebe31 to
5329e2f
Compare
- Remove unused hasSudo flag and err field - Use strings.SplitSeq for range loops (modernize) - Use WaitGroup.Go in bench test (modernize) - Use min() builtin for viewport bounds (modernize)
|
@sebastianbreguel Thanks for the work here. I spent some time comparing this against the current command surface, and I’m going to close this one for now. The main issue is product scope rather than implementation quality. There are a few ideas here that could make sense later in a much smaller form inside existing commands, but I do not want to merge a new standalone diagnostic surface in its current shape. Thanks again for putting this together. |
|
@tw93 Thanks for the thoughtful review — totally understand the concern about overlap and maintenance cost. Looking at it more carefully, I agree For
For
New territory (no current home):
Happy to pick whichever subset makes sense and submit them as small PRs into the existing commands. Or if none of these fit the product direction, no worries at all — appreciate the feedback either way! |
|
@sebastianbreguel Thank you very much. It's okay. You can merge the necessary submissions into the ability first. |
Design for adding broken launch agents, dev tool presence, and version mismatch checks to mo optimize/check flow. Based on tw93's feedback from PR tw93#659 to integrate doctor features into existing commands.
Summary
mo doctor— a TUI-based Mac health diagnostic that scores your system across 7 categories (100 points total). Categories appear one-by-one with a spinner during scanning, then transition to an interactive view where you can expand each category for details.What it checks
Storage (15 pts)
Performance (20 pts)
Battery (15 pts) — skipped on desktops
Security (15 pts)
Maintenance (15 pts)
Dev Environment (15 pts)
Mole (5 pts)
UX
Test plan
go build ./cmd/doctor/succeeds (darwin + linux stub)go test ./cmd/doctor/— all tests passgo vet ./cmd/doctor/— clean