Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Take Homebrew's record of an app along when the app goes
Țugui Dragoșc47ef1e4444f
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.mdindex f9e7115c..9f6f5095 100644--- a/ARCHITECTURE.md+++ b/ARCHITECTURE.md@@ -64,7 +64,8 @@ Take the most common case, uninstalling an app. Every other page follows the sam1. **Scan.** `Uninstallation.prepare` asks `LeftoverScanner` to look through every place an app keeps files(`SearchLocation`): Application Support, Caches, Containers, Preferences, launch agents, plug-in folders, the- top of the home folder, and more, and adds what a Homebrew cask or an installer's receipt names for the app.+ top of the home folder, and more, and adds what a Homebrew cask or an installer's receipt names for the app,+ and the cask's own folder in Homebrew's Caskroom when Homebrew installed it (`HomebrewPackage.caskroomFolder`).A page's scan runs through its `ScanRun`, so a newer scan or the Stop button ends an older one, and it countswhat it reads so the page can show progress.2. **Match.** For each file, `LeftoverMatcher` weighs the evidence that it belongs to the app: its bundlediff --git a/GUIDE.md b/GUIDE.mdindex c4c93f94..847bcb18 100644--- a/GUIDE.md+++ b/GUIDE.md@@ -22,7 +22,8 @@ and how to get it, [SAFETY.md](SAFETY.md) what it protects, [PRIVACY.md](PRIVACYapp's maker or signing team also uses, waits under Review Before Removing. A list's Select menu has SelectRecommended, Select All, and Deselect All. Select All passes by what Peel holds back for what it may hold, whatit only guesses at, and what another app or another copy of the app also uses, which you select one by one, and- asks before it adds anything else Peel doesn't recommend.+ asks before it adds anything else Peel doesn't recommend. The folder Homebrew keeps for an app it installed is+ selected too, so that Homebrew stops listing the app once it is gone.- **Several ways in.** Choose an app in the list, drop one on Peel's Dock icon, select several apps at once, orControl-click an app in Finder and choose Uninstall with Peel, once the Finder extension is on in SystemSettings. With Watch the Trash on, Peel notices when you drag an app to the Trash yourself and offers to cleardiff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 7956040a..5f6c8bb8 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -47166,6 +47166,112 @@}}},+ "Homebrew Receipt" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Záznam Homebrew"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew-Quittung"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Recibo de Homebrew"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Reçu Homebrew"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ricevuta Homebrew"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrewレシート"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew 수신 정보"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew-bewijs"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Potwierdzenie Homebrew"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Recibo do Homebrew"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Recipisă Homebrew"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Квитанция Homebrew"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew-kvitto"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew Makbuzu"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Квитанція Homebrew"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew回执"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew收據"+ }+ }+ }+ },"Homebrew adds the links missing from its taps’ manual pages and shell completions, and points a tap whose main branch was renamed at the new name. It deletes nothing." : {"localizations" : {"cs" : {@@ -147258,6 +147364,112 @@}}},+ "The app’s Homebrew receipt" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Záznam Homebrew o instalaci aplikace"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Die Homebrew-Quittung der App"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "El recibo de Homebrew de la app"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Reçu Homebrew de l’app"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "La ricevuta Homebrew dell’app"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "アプリのHomebrewレシート"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "앱의 Homebrew 수신 정보"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Het Homebrew-installatiebewijs van de app"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Potwierdzenie instalacji aplikacji przez Homebrew"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O recibo do app no Homebrew"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Recipisa Homebrew a aplicației"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Квитанция Homebrew для приложения"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Appens Homebrew-kvitto"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Uygulamanın Homebrew makbuzu"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Квитанція Homebrew для програми"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "App的Homebrew回执"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "App的Homebrew收據"+ }+ }+ }+ },"The app’s identifier" : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex 6311599a..eac945e1 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -271,6 +271,7 @@ extension MatchReason {case .linksToTheApp: "leads into the app"case .nativeMessagingHost: "lets a browser extension run the app"case .installerReceipt: "installer receipt"+ case .homebrewReceipt: "Homebrew receipt"case .homebrewCask: "Homebrew cask"}}diff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swiftindex 42d2ed66..fa051051 100644--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift@@ -47,6 +47,8 @@ public struct HomebrewPackage: Sendable, Hashable, Identifiable {/// The entries of `packageIdentifiers` whose receipts are installed, lowercased. `noting(receipts:)` sets/// them, so the cask carries this proof to every place that checks it.public private(set) var receiptsOnThisMac: [String] = []+ /// An installed cask's folder in Homebrew's Caskroom (`brew --caskroom <token>`), set by `kept(inCaskroom:)`.+ public private(set) var caskroomFolder: URL?public var id: String { "\(kind.rawValue)/\(name)" }@@ -65,6 +67,12 @@ public struct HomebrewPackage: Sendable, Hashable, Identifiable {return noted}+ public func kept(inCaskroom caskroom: URL) -> HomebrewPackage {+ var kept = self+ kept.caskroomFolder = caskroom.appending(path: name, directoryHint: .isDirectory)+ return kept+ }+public init(name: String,kind: Kind,@@ -474,7 +482,8 @@ public enum Homebrew {@concurrentpublic static func installedPackages() async throws(CommandFailure) -> [HomebrewPackage] {let output = try await answer(["info", "--json=v2", "--installed"])- guard let packages = parseInstalled(Data(output.utf8)) else {+ let caskroom = (try? await answer(["--caskroom"])).flatMap(caskroom(answering:))+ guard let packages = parseInstalled(Data(output.utf8), caskroom: caskroom) else {throw CommandFailure(output: output)}return packages@@ -753,7 +762,13 @@ public enum Homebrew {return Set(line.dropFirst(prefix.count).split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) })}- static func parseInstalled(_ data: Data) -> [HomebrewPackage]? {+ static func caskroom(answering answer: String) -> URL? {+ let lines = answer.split(whereSeparator: \.isNewline)+ guard lines.count == 1, let path = lines.first.map(String.init), path.hasPrefix("/") else { return nil }+ return URL(filePath: path, directoryHint: .isDirectory)+ }++ static func parseInstalled(_ data: Data, caskroom: URL? = nil) -> [HomebrewPackage]? {guard let response = try? JSONDecoder().decode(InfoResponse.self, from: data) else { return nil }let formulae = response.formulae.map { formula in@@ -775,7 +790,7 @@ public enum Homebrew {)}let casks = response.casks.map { cask in- HomebrewPackage(+ let package = HomebrewPackage(name: cask.token,kind: .cask,fullName: cask.fullToken,@@ -800,6 +815,8 @@ public enum Homebrew {} ?? false,uninstallNeedsAnAdministrator: cask.artifacts?.contains(where: \.uninstallNeedsAnAdministrator) ?? false)+ guard let caskroom, cask.installed != nil else { return package }+ return package.kept(inCaskroom: caskroom)}return (formulae + casks).sorted { $0.name.localizedStandardCompare($1.name) == .orderedAscending }}diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swiftindex 713dac25..d1191810 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift@@ -17,6 +17,8 @@ public enum MatchReason: String, Sendable, Hashable {case nativeMessagingHost/// An installer receipt for this app's identifier, which keeps macOS counting the package as installed.case installerReceipt+ /// The folder of the Homebrew cask that installed the app, which keeps Homebrew counting it as installed.+ case homebrewReceipt/// The app's Homebrew cask lists this path in its uninstall or zap stanza.case homebrewCask}diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swiftindex ec1ce227..28afbb6a 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift@@ -203,7 +203,7 @@ extension LeftoverMatcher {rank = Self.tier(of: reason) * 10_000 + specificityfamily = switch reason {case .bundleIdentifier, .embeddedBundleIdentifier, .applicationGroup, .bundleIdentifierPrefix,- .launchdJob, .linksToTheApp, .nativeMessagingHost, .installerReceipt:+ .launchdJob, .linksToTheApp, .nativeMessagingHost, .installerReceipt, .homebrewReceipt:.identifiercase .name, .namePrefix, .homebrewCask: .namecase .teamIdentifier, .vendorPrefix: .maker@@ -225,7 +225,7 @@ extension LeftoverMatcher {// A job's or a manifest's program, or a link's target, lies inside the app's bundle, which no other app// can share.case .launchdJob, .linksToTheApp, .nativeMessagingHost: 8- case .bundleIdentifier, .installerReceipt: 7+ case .bundleIdentifier, .installerReceipt, .homebrewReceipt: 7case .embeddedBundleIdentifier, .applicationGroup: 6case .bundleIdentifierPrefix: 5case .name: 4diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swiftindex 34aa8728..872e1715 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift@@ -28,6 +28,8 @@ public struct SearchLocation: Sendable, Hashable {case frameworks/// The two files that are an installer receipt, which is how macOS still counts a package as installed.case receipts+ /// An installed cask's folder in Homebrew's Caskroom, which holds Homebrew's record that it installed the app.+ case homebrewReceipt/// The top of a Library itself, where a vendor keeps a folder of its own beside macOS's.case librarycase temporaryItemsdiff --git a/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift b/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swiftindex 8fd41e2f..8fffe5e3 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift@@ -96,7 +96,7 @@ public struct AppReset: Sendable {// A reset leaves these alone. What every account on the Mac shares is not one user's to reset, and a// plug-in or a framework is code that macOS loads, not a setting.case .launchAgents, .launchDaemons, .privilegedHelperTools, .startupItems, .plugIns, .frameworks, .receipts,- .library,+ .homebrewReceipt, .library,.sharedFolder, .hiddenHomeFiles, .homeFolder, .commandLineTools, .shellCompletions, .nativeMessagingHosts,.elsewhere:nildiff --git a/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift b/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swiftindex 635ef2b0..bd0624fa 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift@@ -62,6 +62,15 @@ public struct Uninstallation: Sendable {scan = scan.adding(await receiptLeftovers(for: app, receipts: receipts, exclusions: exclusions, environment: environment))+ scan = scan.adding(+ await homebrewReceipt(+ of: app,+ casks: casks,+ installedApps: installedApps,+ exclusions: exclusions,+ environment: environment+ )+ )let uninstallsItself = UninstallsItself.of(app, environment: environment)if let uninstallsItself {scan = scan.leavingToItsUninstaller(uninstallsItself)@@ -108,6 +117,41 @@ public struct Uninstallation: Sendable {return leftovers}+ /// The folder of the cask Homebrew installed the app from, which keeps Homebrew counting the app as installed once+ /// it is gone, and which `brew uninstall` would delete for good. Another app of the cask still in place shares it.+ static func homebrewReceipt(+ of app: InstalledApp,+ casks: [HomebrewPackage],+ installedApps: [InstalledApp],+ exclusions: Exclusions,+ environment: SearchEnvironment+ ) async -> [Leftover] {+ guard+ let cask = CaskEvidence.installedCask(for: app, in: casks),+ let folder = cask.caskroomFolder,+ FileAccess.isARealFolder(folder),+ !exclusions.excludes(folder)+ else { return [] }+ let bundle = PathPattern.comparablePath(of: app.url)+ let others = cask.appTargets.filter { target in+ target.caseInsensitiveCompare(bundle) != .orderedSame && FileManager.default.fileExists(atPath: target)+ }+ let sharedWith = others.map { target in+ let installed = installedApps.first {+ PathPattern.comparablePath(of: $0.url).caseInsensitiveCompare(target) == .orderedSame+ }+ return installed?.bundleIdentifier ?? Bundle(url: URL(filePath: target))?.bundleIdentifier ?? target+ }+ let leftover = await LeftoverScanner.leftover(+ at: folder,+ kind: .homebrewReceipt,+ match: LeftoverMatch(reason: .homebrewReceipt, confidence: .certain, sharedWith: sharedWith.sorted()),+ parent: ParentAccess(folder.deletingLastPathComponent()),+ home: environment.homeDirectory.path(percentEncoded: false)+ )+ return [exclusions.holds(folder) ? leftover.heldBack(.holdsAnExclusion) : leftover]+ }+/// Leftovers for the paths a cask names (`LeftoverScan.adding` drops those the scanner already found)./// Homebrew warns that `zap` may remove what other apps share, and a vendor's shared folder is exactly what/// only a cask would name. So a path in a Library is `likely` only when the app's own matcher also matches it.diff --git a/Packages/PeelCore/Sources/PeelCore/Support/FileAccess.swift b/Packages/PeelCore/Sources/PeelCore/Support/FileAccess.swiftindex 8c83e1e2..7b8c1144 100644--- a/Packages/PeelCore/Sources/PeelCore/Support/FileAccess.swift+++ b/Packages/PeelCore/Sources/PeelCore/Support/FileAccess.swift@@ -20,6 +20,11 @@ public enum FileAccess {accessError == EPERM && !isLocked}+ static func isARealFolder(_ url: URL) -> Bool {+ var info = stat()+ return lstat(url.path(percentEncoded: false), &info) == 0 && info.st_mode & S_IFMT == S_IFDIR+ }+/// Whether `url` is locked (`chflags uchg` or `schg`), which blocks a move whatever the permissions say.static func isLocked(_ url: URL) -> Bool {var info = stat()diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewReceiptTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewReceiptTests.swiftnew file mode 100644index 00000000..68910e43--- /dev/null+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewReceiptTests.swift@@ -0,0 +1,153 @@+import Foundation+@testable import PeelCore+import Testing++struct HomebrewReceiptTests {+ private let json = """+ {"formulae": [], "casks": [+ {"token": "example", "installed": "1.0", "version": "1.0",+ "artifacts": [{"app": ["Example.app"], "target": "/Applications/Example.app"}]},+ {"token": "other", "version": "2.0"}+ ]}+ """++ @Test func anInstalledCaskKnowsItsFolderInTheCaskroom() throws {+ let caskroom = URL(filePath: "/opt/homebrew/Caskroom", directoryHint: .isDirectory)++ let casks = try #require(Homebrew.parseInstalled(Data(json.utf8), caskroom: caskroom))++ let folder = casks.first { $0.name == "example" }?.caskroomFolder+ #expect(folder?.path(percentEncoded: false) == "/opt/homebrew/Caskroom/example/")+ #expect(casks.first { $0.name == "other" }?.caskroomFolder == nil)+ }++ @Test func readsTheCaskroomHomebrewNames() {+ #expect(Homebrew.caskroom(answering: "/opt/homebrew/Caskroom\n")?.path(percentEncoded: false)+ == "/opt/homebrew/Caskroom/")+ #expect(Homebrew.caskroom(answering: "") == nil)+ #expect(Homebrew.caskroom(answering: "Caskroom\n") == nil)+ #expect(Homebrew.caskroom(answering: "/opt/homebrew/Caskroom\n/usr/local/Caskroom\n") == nil)+ }++ @Test func everyCaskInstalledOnThisMacHasItsFolder() async throws {+ guard Homebrew.executableURL != nil, await Homebrew.hasLocalDefinitions() else { return }++ for cask in try await Homebrew.installedPackages() where cask.kind == .cask {+ let folder = try #require(cask.caskroomFolder, "\(cask.name)")+ var isFolder: ObjCBool = false+ #expect(FileManager.default.fileExists(atPath: folder.path(percentEncoded: false), isDirectory: &isFolder))+ #expect(isFolder.boolValue, "\(folder.path())")+ }+ }++ private struct Installed: ~Copyable {+ let directory: TemporaryDirectory+ let environment: SearchEnvironment+ let caskroom: URL++ init() throws {+ let directory = try TemporaryDirectory()+ try directory.file("root/opt/homebrew/Caskroom/example/.metadata/1.0/20261007000000.000/Casks/example.json")+ environment = SearchEnvironment(+ homeDirectory: directory.url.appending(path: "home", directoryHint: .isDirectory),+ rootDirectory: directory.url.appending(path: "root", directoryHint: .isDirectory)+ )+ caskroom = directory.url.appending(path: "root/opt/homebrew/Caskroom", directoryHint: .isDirectory)+ self.directory = directory+ }++ func app(_ name: String, identifier: String) throws -> InstalledApp {+ InstalledApp(+ url: try directory.directory("root/Applications/\(name).app"),+ bundleIdentifier: identifier,+ name: name+ )+ }++ func service() throws -> TrashService {+ let trash = try directory.directory("home/.Trash")+ return TrashService(environment: environment) { url in+ let destination = trash.appending(path: url.lastPathComponent)+ try FileManager.default.moveItem(at: url, to: destination)+ return destination+ }+ }++ func cask(installing apps: [InstalledApp]) -> HomebrewPackage {+ HomebrewPackage(+ name: "example",+ kind: .cask,+ installedVersion: "1.0",+ appNames: apps.map(\.url.lastPathComponent),+ appTargets: apps.map { PathPattern.comparablePath(of: $0.url) }+ ).kept(inCaskroom: caskroom)+ }+ }++ @Test func theAppTakesItsHomebrewReceiptAlong() async throws {+ let installed = try Installed()+ let app = try installed.app("Example", identifier: "org.example.app")++ let plan = await Uninstallation.prepare(+ app, installedApps: [app], casks: [installed.cask(installing: [app])], environment: installed.environment+ )++ let row = try #require(plan.scan.leftovers.first { $0.kind == .homebrewReceipt })+ #expect(PathPattern.comparablePath(of: row.url)+ == PathPattern.comparablePath(of: installed.caskroom.appending(path: "example")))+ #expect(row.match.reason == .homebrewReceipt)+ #expect(row.match.isRecommended)+ #expect(plan.suggestedSelection(canUseHelper: false).contains(row.url))+ #expect(plan.removalOrder(of: [row.url, app.url]) == [app.url, row.url])+ }++ @Test func aCaskWhoseOtherAppStaysKeepsItsReceipt() async throws {+ let installed = try Installed()+ let app = try installed.app("Example", identifier: "org.example.app")+ let other = try installed.app("Example Helper", identifier: "org.example.helper")++ let plan = await Uninstallation.prepare(+ app,+ installedApps: [app, other],+ casks: [installed.cask(installing: [app, other])],+ environment: installed.environment+ )++ let row = try #require(plan.scan.leftovers.first { $0.kind == .homebrewReceipt })+ #expect(row.match.sharedWith == ["org.example.helper"])+ #expect(!plan.suggestedSelection(canUseHelper: false).contains(row.url))+ }++ @Test func theReceiptGoesToTheTrashAfterTheApp() async throws {+ let installed = try Installed()+ let app = try installed.app("Example", identifier: "org.example.app")+ let plan = await Uninstallation.prepare(+ app, installedApps: [app], casks: [installed.cask(installing: [app])], environment: installed.environment+ )++ let result = await plan.move(plan.suggestedSelection(canUseHelper: false), using: try installed.service())++ #expect(result.failures.isEmpty, "\(result.failures.map(\.reason))")+ #expect(result.trashed.map(\.originalURL.lastPathComponent) == ["Example.app", "example"])+ }++ @Test func aCaskTakesItsReceiptAlongOnlyWithAllItsApps() async throws {+ let installed = try Installed()+ let app = try installed.app("Example", identifier: "org.example.app")+ let other = try installed.app("Example Helper", identifier: "org.example.helper")+ let cask = installed.cask(installing: [app, other])++ let both = await BulkUninstallation.prepare(+ [app, other], installedApps: [app, other], casks: [cask], environment: installed.environment+ )+ let one = await BulkUninstallation.prepare(+ [app], installedApps: [app, other], casks: [cask], environment: installed.environment+ )++ #expect(both.items.first { $0.kind == .homebrewReceipt }?.isRecommended == true)+ #expect(one.items.first { $0.kind == .homebrewReceipt }?.isRecommended == false)+ let result = await both.move(Set(both.items.filter(\.isRecommended).map(\.url)), using: try installed.service())+ #expect(result.failures.isEmpty, "\(result.failures.map(\.reason))")+ #expect(result.trashed.last?.originalURL.lastPathComponent == "example")+ }+}diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swiftindex 3fa4fae6..1ad74620 100644--- a/Peel/Views/AppDetailView.swift+++ b/Peel/Views/AppDetailView.swift@@ -428,7 +428,7 @@ struct AppDetailView: View {}/// The confirmation's message: the privacy reset, which History can't undo, an app that uninstalls itself once- /// it moves, and Homebrew's own record of the app, which moving the app doesn't touch.+ /// it moves, and Homebrew's own record of the app when it stays.private var removalNote: Text? {let urls = plan.question.request?.urls ?? []var lines: [Text] = []@@ -436,7 +436,10 @@ struct AppDetailView: View {lines.append(Text("The app’s privacy permissions are cleared first, and History can’t bring them back."))}lines += UninstallsItself.when(moving: urls, among: [plan.app]).map(\.warning)- if urls.contains(plan.app.url), let cask = library.cask(for: plan.app) {+ let movesItsReceipt = plan.uninstallation?.scan.leftovers.contains {+ $0.kind == .homebrewReceipt && urls.contains($0.url)+ } == true+ if urls.contains(plan.app.url), !movesItsReceipt, let cask = library.cask(for: plan.app) {lines.append(Text("Homebrew installed this app and will keep listing it as installed. To take it off that list, run `brew uninstall --cask \(cask.name)`: Homebrew then carries out the cask’s own uninstall steps, which can delete files for good."))}guard let first = lines.first else { return nil }diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex f4a9ef0b..83597f1f 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -16,6 +16,7 @@ extension MatchReason {case .linksToTheApp: "Leads to a tool inside the app"case .nativeMessagingHost: "Lets a browser extension run a program inside the app"case .installerReceipt: "The app’s installer receipt"+ case .homebrewReceipt: "The app’s Homebrew receipt"case .homebrewCask: "Listed by the Homebrew cask"}}@@ -70,6 +71,7 @@ extension SearchLocation.Kind {case .plugIns: "Plug-in"case .frameworks: "Framework"case .receipts: "Installer Receipt"+ case .homebrewReceipt: "Homebrew Receipt"case .library: "Library Folder"case .temporaryItems: "Temporary Files"case .commandLineTools: "Command-Line Tool"@@ -103,6 +105,7 @@ extension SearchLocation.Kind {case .plugIns: "powerplug"case .frameworks: "books.vertical"case .receipts: "doc.text.below.ecg"+ case .homebrewReceipt: "mug"case .library: "building.columns"case .sharedFolder: "person.2"case .hiddenHomeFiles: "eye.slash"diff --git a/SAFETY.md b/SAFETY.mdindex b891b596..2c4db861 100644--- a/SAFETY.md+++ b/SAFETY.md@@ -122,11 +122,13 @@ link moves the link.Peel never deletes anything of yours. Everything it removes goes to the Trash, and everything is recorded soHistory can put it back; History keeps the most recent 20,000 items, and what it forgets is still in the Trash.That includes an installer receipt you ask Peel to forget: the two files that make it up go to the Trash-through the helper, where `pkgutil --forget` would have discarded them for good. Quitting Peel waits for a-removal until History has it, `peel` carries on through Ctrl-C or a closed terminal until it has written History,-and each item is written down the moment it moves, so one cut short by a crash or Force Quit still reaches-History, as an interrupted removal, the next time Peel or `peel` opens it. The space is freed when *you* empty-the Trash: Peel never does that for you.+through the helper, where `pkgutil --forget` would have discarded them for good. So does the folder Homebrew keeps+for an app it installed (`brew --caskroom`), which `brew uninstall` would delete: it goes after the app,+Homebrew stops listing the app, and History puts both back. Quitting Peel waits for a removal until History has+it, `peel` carries on through Ctrl-C or a closed terminal until it has written History, and each item is written+down the moment it moves, so one cut short by a crash or Force Quit still reaches History, as an interrupted+removal, the next time Peel or `peel` opens it. The space is freed when *you* empty the Trash: Peel never does+that for you.Right before anything moves, Peel looks at the files other programs of yours hold open and at the program eachprocess runs, and leaves where it is any file or folder with one of them inside, naming the program: moving a