1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 19:05:07 +00:00
Commit Graph

704 Commits

Author SHA1 Message Date
Tw93
0c71ee9363 fix(main): preserve versioned app names and clean mise cache 2026-03-22 14:45:21 +08:00
Tw93
4f178c1d7a fix(clean/uninstall): harden external cleanup accounting and relative app symlink resolution 2026-03-21 16:06:44 +08:00
Tw93
599ea21a22 perf(optime): parallelize and harden brew outdated checks 2026-03-21 16:06:37 +08:00
Tw93
c5d6cdc2f9 perf(purge/uninstall): eliminate per-item subprocess forks in scan phase
purge:
- is_safe_project_artifact: replace echo|tr|wc depth calc with pure bash
  string arithmetic (2 forks → 0 per item)
- process_scan_results: replace dirname subprocess with ${item%/*}
- is_recently_modified: accept pre-computed epoch to avoid redundant
  get_epoch_seconds call (N date forks → 1 before loop)
- fd pattern construction: replace 45 per-target sed forks with single
  printf|sed pass (45 forks → 2)
- pre-compute _cached_project_paths alongside existing name/basename
  cache so display loop avoids get_project_path subshell per item

uninstall/app-selector:
- default size display: N/A → -- for apps without cached size data
  (cleaner UX on first scan; real sizes populate from background refresh)
- Pass 1 scan: replace basename/dirname subshells with parameter expansion
2026-03-21 15:33:57 +08:00
Tw93
4f07a5aa0a perf(clean): speed up scan phase across all modules
- Parallelize project cache indicator checks and root scans in caches.sh
  (sequential find per $HOME/* dir → throttled background jobs)
- Pre-compute project name cache before purge display loop, eliminating
  O(N²) filesystem traversals in get_artifact_display_name
- Replace basename/dirname subshells with parameter expansion in
  get_project_name/get_project_path hot loops; depth counter via
  bash string arithmetic instead of echo|tr|wc|tr pipeline
- Eliminate mktemp/awk/rm per call in app_support_item_size_bytes,
  use command substitution to capture du output directly
- Defer tr lowercase in clean_application_support_logs to only when
  first 3 protection checks fail; replace basename with ${var##*/}
- Optimize trash item counting: find -print0|tr -dc '\0'|wc -c
  avoids per-file fork from -exec printf
- Add -maxdepth 5 to /private/var/folders find (X dir is always at
  depth 3, code_sign_clone at depth 5 max; verified on real machine)
2026-03-21 15:19:32 +08:00
Tw93
694c191c6f fix: correct glob expansion in downloads cleanup, add purge index bounds guard, update security audit
- lib/clean/user.sh: quote glob patterns in _clean_incomplete_downloads so
  they are not expanded at array assignment time; filenames with spaces would
  previously be word-split before reaching safe_clean, causing silent failures
- lib/clean/project.sh: replace silent array fallback with explicit bounds
  check before reading PURGE_CATEGORY_FULL_PATHS_ARRAY, guarding against
  future index drift if menu filtering is added
- SECURITY_AUDIT.md: document double validatePath in analyze delete, native
  PAM passthrough for sudo prompts, dry-run dedup by filesystem identity,
  atomic purge config write, pre-commit hook mirroring CI, and new test suites
2026-03-21 14:17:52 +08:00
Tw93
d6b9d9f3f3 Fix cleanup regressions and analyze navigation
Refs #605 #607 #608 #609 #610
2026-03-21 13:05:21 +08:00
Yuval Dinodia
7403f4d35e fix: pass through sudo's native prompt instead of hardcoding 'Password:' (#599)
* pass through sudo prompt instead of hardcoding Password:

* simplify: remove redundant retry loop, sudo handles retries internally

* keep stty safety net and styled prefix

* fix: clear clamshell sudo prompt lines correctly

---------

Co-authored-by: Tw93 <hitw93@gmail.com>
2026-03-21 07:33:44 +08:00
Tw93
584e10cdc4 fix(log): preserve Mole runtime logs during clean 2026-03-19 09:52:27 +08:00
Tw93
3b46b4ade6 fix(ui): use system sleep for inline spinner 2026-03-19 00:40:39 +08:00
Tw93
821a824d81 fix: dedupe cleanup previews by filesystem identity 2026-03-19 00:32:28 +08:00
Jason Costello
e617ed2e76 Fix: Removed duplicate calls to clean_xcode_tools and clean_code_editors (#593)
* removed duplicate calls to clean_xcode_tools and clean_code_editors

in lib/clean/app_caches.sh clean_user_gui_application() was making calls
to clean_xcode_tools and clean_code_editors.

in lib/clean/dev.sh clean_xcode_tools and clean_code_editors was also
being called, causing the duplication when executing the clean command.

removed the calls from lib/clean/app_caches.sh
clean_user_gui_application since these two calls are developer focused.

* test: cover removed developer app calls

---------

Co-authored-by: Tw93 <hitw93@gmail.com>
2026-03-19 00:25:49 +08:00
Tw93
06d2a3d029 fix: keep tealdeer tldr pages cache 2026-03-19 00:24:54 +08:00
Tw93
6e1048a70a Revert "fix(ui): unify ICON_LIST dot size with ICON_SOLID"
This reverts commit 112d134829.
2026-03-18 15:24:07 +08:00
Tw93
112d134829 fix(ui): unify ICON_LIST dot size with ICON_SOLID
Change ICON_LIST from • (small bullet) to ● (filled circle) so both
checkbox indicators and list bullets render at the same balanced size.
2026-03-18 15:17:03 +08:00
Tw93
702f299e78 fix(ui): rename Filter to Search in paginated menu 2026-03-18 14:55:20 +08:00
Tw93
5a2a5d9179 fix(uninstall): detect bundle-id-derived extension leftovers
Scan Application Scripts, Containers and FileProvider directories for
entries that share the app bundle-id prefix (e.g. share extensions,
file-provider extensions) so they are included in uninstall cleanup.
2026-03-18 14:54:59 +08:00
Tw93
fa935548b0 fix(optimize): warn before bluetooth refresh
Show "Bluetooth devices may disconnect briefly during refresh" before
actually restarting bluetoothd, so the user is not surprised by a
momentary disconnect.
2026-03-18 14:50:04 +08:00
Tw93
b8f3a0ecd3 fix(clean): avoid container cache scan stalls
Add a lightweight top-level entry cap to Containers and Group
Containers scanning.  When a cache directory exceeds the threshold,
skip the expensive per-item du/find size scan and take a partial-size
/ "cleaned" output path instead.  Replace find-piped-to-read loops
with pure-bash glob iteration to cut external process overhead.

Closes #586
2026-03-18 14:49:12 +08:00
Tw93
f88b2116ab fix(check): use softwareupdate output for macOS update detection
Replace LastRecommendedUpdatesAvailable defaults check with unified
softwareupdate -l --no-scan parsing.  Add caching layer and teach the
parser to distinguish macOS updates, Background Security Improvements,
Rapid Security Responses, and non-macOS entries so each gets an
accurate title in the output.

Fix reset_softwareupdate_cache() to also reset the in-memory
SOFTWARE_UPDATE_LIST_LOADED flag, and add a regression test.

Closes #585
2026-03-18 14:48:39 +08:00
Tw93
25892594b0 fix: show full purge paths during confirmation
Fixes #576
2026-03-17 19:20:32 +08:00
Tw93
6c53906427 fix brew uninstall fallback consistency 2026-03-17 16:39:42 +08:00
Tw93
e1f427c9aa fix: stop cleaning aerial wallpaper assets by default 2026-03-17 16:35:10 +08:00
Tw93
ea4cd9d0e3 fix(tests): prevent permission dialogs during test runs
Add MOLE_TEST_MODE=1 checks to skip AppleScript osascript calls
and sudo operations that trigger system permission dialogs during tests:

- lib/check/all.sh: Skip login items listing
- lib/clean/apps.sh: Skip running app detection
- lib/clean/user.sh: Skip Finder trash operations and sudo test calls
- lib/core/log.sh: Skip sudo status check in debug log
- lib/uninstall/batch.sh: Skip login item removal

Also add MOLE_TEST_MODE=1 export to all test files that load
these modules to ensure consistent test isolation.
2026-03-16 20:43:35 +08:00
Tw93
cfa0a82057 fix: skip incomplete downloads that are actively in use
Before deleting .download/.crdownload/.part files, check lsof to
detect open file handles. Files held by an active browser process
are skipped with a warning instead of being deleted.

Fixes a case where a 12GB IPSW being downloaded in Safari was
removed mid-download because the .download bundle matched the glob.
2026-03-16 07:39:41 +08:00
Tw93
30c1a95731 Harden test mode against auth and uninstall side effects 2026-03-15 12:19:50 +08:00
Tw93
7a0b4cf07e fix: move logs to ~/Library/Logs/mole, add system idle assets cleanup
- Move log files from ~/.config/mole/ to ~/Library/Logs/mole/ per
     macOS convention. Fixes #569.
   - Add safe_sudo_find_delete for /Library/Application Support/
     com.apple.idleassetsd/Customer/ screensaver videos. Closes #570.
   - Update tests to reflect new log file paths.
2026-03-15 11:38:18 +08:00
Tw93
45c98c2ec8 fix: explicitly skip system binary launch agents and harden test isolation
Add hint_is_system_binary() to short-circuit detection for plists that
use /bin/*, /usr/bin/*, /usr/libexec/* etc. as their program path.
These are custom scripts, not app-backed launch agents, so the stale
detection logic does not apply. Previously the function relied on the
absence of AssociatedBundleIdentifiers as an implicit skip, which could
fail on certain macOS plutil edge cases.

Also add teardown() in clean_hints.bats to explicitly remove the
LaunchAgents directory after each test, and add run_with_timeout mock
in the "skips custom shell wrappers" test to prevent mdfind from
influencing results. This eliminates the intermittent failure where
test 70 showed "Review:" in output without "Potential stale login item:".
2026-03-15 08:55:17 +08:00
Tw93
a6931dab5b fix: clean HTTPStorages binarycookies files and Preferences directories on uninstall
Add ~/Library/HTTPStorages/<bundle-id>.binarycookies to targeted uninstall
cleanup. WKWebView creates both a directory and a .binarycookies file under
HTTPStorages; only the directory was previously covered. Affected apps include
cmux (com.cmuxterm.app) and Tuna (com.brnbw.Tuna).

Also add ~/Library/Preferences/<bundle-id> directory detection for apps like
VLC (org.videolan.vlc) that store preferences in a directory rather than a
.plist file.
2026-03-14 23:20:18 +08:00
Tw93
2e6553ab2b Protect user launch agents during clean 2026-03-14 22:32:53 +08:00
Tw93
169be1e1f2 fix(timeout): inherit helper state and pass checks 2026-03-14 08:32:11 +08:00
Tw93
ea37d3e356 fix(purge): remove 60-char hard cap on path display width (issue #564)
The path column in 'mo purge' selection was capped at 60 characters
regardless of terminal width. On wide terminals (120+ cols) this caused
long project paths like ~/GitHub/Ulama/transformer-project to be
truncated unnecessarily to ~17 visible characters.

Remove the hard 60-char cap and let the available terminal space be the
only upper bound, which is already computed as:
  available_for_path = terminal_width - fixed_overhead

Paths now use as much space as the terminal allows while still keeping
the size and artifact-type columns readable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-14 07:46:44 +08:00
Tw93
97d35c03d6 fix(purge): parallelize size calculations to prevent hang (issue #560)
Sequential du calls with 15s timeout each meant N artifacts × 15s of potential
wait when paths are on slow storage (network mounts, Syncthing, large dirs).
Now all du processes are launched concurrently; total time is bounded by the
single longest call (≤ 15s) rather than N × 15s.

fix(protection): protect CoreAudio paths in should_protect_path (issue #553)

Add com.apple.coreaudio*, com.apple.audio.*, and coreaudiod* to the protected
path patterns so deep-clean cannot touch audio subsystem caches, reducing risk
of audio output loss on Intel Macs running macOS Sequoia.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-14 00:00:08 +08:00
c5d923cd48 fix(appli-support):using whitelist in application_support clean (#562)
* fix(appli-support):using whitelist in application_support clean

* fix: harden clash verge app support protection

---------

Co-authored-by: Tw93 <hitw93@gmail.com>
2026-03-13 11:38:37 +08:00
Nour
65b0db4e1c feat(clean): add opt-in Docker unused data pruning (#554)
* feat(clean): add opt-in Docker unused data pruning

* fix(clean): make docker prune default

---------

Co-authored-by: Tw93 <hitw93@gmail.com>
2026-03-10 16:20:40 +08:00
Tw93
af84d6f4be docs: strengthen public security signals 2026-03-10 15:31:07 +08:00
tw93
24da1e2ac1 fix(clean): speed up Python bytecode cache cleanup 2026-03-08 19:45:53 +08:00
tw93
2a36c662aa fix: tighten orphan cleanup retention windows 2026-03-08 15:33:30 +08:00
tw93
26b267c4a2 fix: harden orphan cleanup and lsregister fallback 2026-03-08 15:29:25 +08:00
tw93
50efe51565 fix(clean): guard empty Xcode DeviceSupport arrays 2026-03-07 23:10:41 +08:00
Tw93
faf29b05f1 Fix perl timeout fallback selection 2026-03-07 20:36:34 +08:00
Onur Taşhan
dfedc029d1 fix: handle empty menu_options in mo purge to prevent unbound variable error (#547)
When no artifacts are found during scanning, `menu_options` remains an
empty array. With `set -euo pipefail` active, expanding `${menu_options[@]}`
on an empty array causes a fatal "unbound variable" error (line 1325).

Add an early-return guard after the spinner stops: if no items were found,
print a friendly "No artifacts found to purge" message and exit cleanly.

Fixes #546
2026-03-07 20:33:47 +08:00
tw93
300aded07b fix(clean): avoid stalls in app support scan 2026-03-07 18:35:19 +08:00
tw93
09d0de0c8e perf(core): optimize base functions with caching and improve robustness
- Add global caching for `detect_architecture`, `get_darwin_major`, `get_optimal_parallel_jobs`, and `is_ansi_supported` to reduce subshell overhead.
- Improve robustness of `get_lsregister_path` by returning 1 on failure.
- Enhance security of `get_user_home` by replacing `eval echo` with `id -P`.
2026-03-06 19:42:15 +08:00
tw93
0fabc6feec fix(shell): suppress SC2016 in timeout perl fallback 2026-03-06 14:17:42 +08:00
Tw93
92ad46a396 fix(clean): harden project cache scans
Refs #541
2026-03-06 07:49:44 +08:00
Tw93
7e69a4eb71 clean orphaned Claude VM bundle
Fixes #537
2026-03-06 07:36:08 +08:00
Tw93
a4890764d3 chore: auto format code 2026-03-05 09:51:52 +00:00
tw93
f91975e5be Refine update/uninstall UX and stabilize brew flows 2026-03-05 17:46:05 +08:00
tw93
2578d0a920 chore: Bump version to 1.29.0 2026-03-05 15:16:55 +08:00