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

248 Commits

Author SHA1 Message Date
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
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
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
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
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
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
169be1e1f2 fix(timeout): inherit helper state and pass checks 2026-03-14 08:32:11 +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
Tw93
af84d6f4be docs: strengthen public security signals 2026-03-10 15:31:07 +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
faf29b05f1 Fix perl timeout fallback selection 2026-03-07 20:36:34 +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
9fea75af25 Merge branch 'main' of https://github.com/tw93/Mole 2026-03-05 13:58:25 +08:00
tw93
8e4b8a5e0d Improve update checks and cleanup UX, add timeout regressions 2026-03-05 12:00:07 +08:00
Noah Qin
a9d7c3912f fix(sudo): add GUI mode support for non-TTY environments (#536)
When Mole is called from GUI applications (e.g., SwiftUI apps), the
request_sudo_access() function would fail with '/dev/tty: Device not
configured' error because /dev/tty is not available in non-TTY contexts.

This commit adds automatic detection of the runtime environment and uses
macOS native password dialog (via osascript) when running in GUI mode,
while preserving all existing TTY behavior including Touch ID support.

Changes:
- Detect TTY availability before attempting terminal-based authentication
- Use osascript to display native password dialog in GUI mode
- Maintain backward compatibility with all terminal-based workflows
- Ensure secure password handling (unset after use)

Fixes commands like 'mole clean', 'mole optimize', 'mole purge' when
invoked from GUI applications.
2026-03-05 09:35:26 +08:00
陳德生
05446e0847 Add dry-run support across destructive commands (#516)
* chore: update contributors [skip ci]

* Add dry-run support across destructive commands

Implement dry-run for uninstall, purge, installer, touchid, completion, and remove flows.\nGuard side effects in uninstall path (launchctl, defaults writes, kill/brew actions), update help/README, and add coverage in CLI/Bats tests.\n\nValidation: ./scripts/check.sh and ./scripts/test.sh (452 tests, 0 failures, 8 skipped).

* test(purge): keep dev-compatible purge coverage

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Tw93 <hitw93@gmail.com>
2026-03-01 20:03:22 +08:00
Tw93
d40783cca9 chore: auto format code 2026-02-28 07:27:33 +00:00
tw93
c8190772ac refactor(core): remove unused utility functions
Remove unused functions from base.sh and ui.sh:
- base.sh: is_interactive, spinner stack management, get_terminal_info, validate_terminal_environment
- ui.sh: with_spinner

Net reduction: ~166 lines of dead code
2026-02-28 15:25:53 +08:00
Tw93
194e8ad29a chore: auto format code 2026-02-28 03:11:16 +00:00
tw93
c19a0276b8 refactor: Update shell arithmetic increment syntax from ((var++)) || true to var=$((var + 1)) across various scripts. 2026-02-28 11:10:18 +08:00
tw93
7d70889ad4 chore: auto format code 2026-02-28 11:03:16 +08:00
tw93
1be71edc9d fix: use Base-10 sizes and mdls logical size to match macOS Finder
- Switch bytes_to_human (shell) and humanizeBytes (Go) from Base-2
  (1024) to Base-10 (1000) to match Apple's storage calculation
  standard since Snow Leopard
- Add proper decimal rounding instead of truncation
- Use mdls kMDItemLogicalSize for .app bundles to avoid APFS clone
  file undercounting by du

Fixes #511
2026-02-28 10:02:34 +08:00
tw93
310abb2510 fix: clean aerial wallpaper videos directly without 30d limit and bypass app protection wildcard, close #508 2026-02-28 09:49:16 +08:00
Tw93
c129591cf4 fix: remove redundant pipefail blocks and fix arithmetic bug
This commit addresses the issue #506 where mole would exit prematurely
during application support scanning.

Changes:
1. Remove 4 redundant pipefail disable/restore blocks:
   - safe_find_delete() in lib/core/file_ops.sh
   - safe_sudo_find_delete() in lib/core/file_ops.sh
   - fix_broken_preferences() in lib/optimize/maintenance.sh
   - opt_saved_state_cleanup() in lib/optimize/tasks.sh

   These were unnecessary because process substitution (< <(cmd)) is not
   affected by pipefail - only real pipelines (cmd1 | cmd2) are.

2. Fix real bug in fix_broken_preferences():
   - Add || true to ((broken_count++)) on lines 35 and 55
   - This prevents set -e from exiting when broken_count starts at 0

Fixes #506
2026-02-27 23:44:10 +08:00
Tw93
013549ad25 fix: temporarily disable pipefail to prevent process substitution failures during cleanup operations 2026-02-27 22:52:38 +08:00
tw93
a9433e4acd fix: preserve interrupt semantics and restore purge traps 2026-02-27 11:18:53 +08:00
tw93
2eb0f2b9b3 fix(log): generate summary divider width from terminal width
Replace hardcoded 70-char string with a dynamically generated divider
capped at terminal width (max 70) so the separator fits narrow terminals
instead of overflowing them.
2026-02-26 19:42:58 +08:00
tw93
aa1a436862 fix(clean): improve loading feedback and spinner output 2026-02-26 16:36:06 +08:00
tw93
88b0fe6af3 refactor(base): extract get_lsregister_path as shared utility
Move get_lsregister_path() to base.sh to avoid duplication across
optimize and uninstall modules. Adds macOS 14+ compatibility with
fallback paths.
2026-02-26 11:53:39 +08:00
tw93
3bd3e400b6 style: improve code consistency and formatting
- Rename _MOLE_HINTS_DIR to mole_hints_dir (naming convention)
- Split local variable declaration and assignment
- Add ICON_INFO constant to base.sh
- Remove redundant has_cached_sudo function (use has_sudo_session)
2026-02-26 11:47:41 +08:00
tw93
3112673ed3 feat(clean): add storage clues after large files 2026-02-23 11:34:04 +08:00
tw93
744ecec4ba fix(clean): use sudo-safe cleanup for Xcode documentation cache 2026-02-15 07:52:43 +08:00
NeedmeFordev
85cd0253d5 feat(uninstall): remove app diagnostic reports from /Library/Logs/DiagnosticReports (fixes #441) (#443)
* Implement deleting files from DiagnosticReports

* fix(uninstall): avoid diagnostic size double-count and set -e exit

---------

Co-authored-by: tw93 <tw93@qq.com>
2026-02-11 14:35:45 +08:00
tw93
172afa83af refactor: centralize subcommand help handlers 2026-02-10 15:06:14 +08:00
tw93
7813124f33 refactor: Extract com.clash.app pattern to avoid ShellCheck redundancy warning 2026-02-09 20:25:10 +08:00
tw93
c8b4b085c6 feat: Add com.clash.app to the list of recognized proxy application patterns. 2026-02-09 20:13:59 +08:00
tw93
b2987b0bb9 feat: add VS Code ShipIt cache directories to cleanup list #427 2026-02-09 19:47:50 +08:00
tw93
e6829b9a5d fix: improve cache freshness fallback and proxy detection 2026-02-07 17:48:55 +08:00
tw93
361d0dda05 fix: P1/P2 issues in file ops, menu state, and logging
- Fix safe_sudo_remove early exit on error (P1)
- Fix menu filter state leakage in paginated menu (P2)
- Fix cleanup of MOLE_MENU_FILTER_NAMES in app selector (P2)
- Correct log_operation signature for memory dumps (P2)
- Apply minor formatting fixes to dev cleanup module
2026-02-07 11:21:37 +08:00