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
List apart in Orphaned Files what only an administrator can remove
Țugui Dragoș1a71f64c227c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ef5309e3..a8e0de93 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -27,6 +27,7 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.- Shows iCloud Drive's downloads in the folders Finder shows them in, and on macOS 27 how far Remove Downloads got,with a way to stop it.- Lists in Orphaned Files what a gone app's own product file named, and browser helpers that start nothing.+- Lists apart in Orphaned Files what only an administrator can remove, with how to remove it in Finder.- On macOS 27, says in History when an audio driver you put back needs a restart, and when an app shared its storagewith a copy.- On macOS 27, says how to delete a network extension in System Settings, even once its app is gone.diff --git a/GUIDE.md b/GUIDE.mdindex 41dbd422..f2c905a0 100644--- a/GUIDE.md+++ b/GUIDE.md@@ -60,7 +60,8 @@ Space shows what fills your disk, area by area, and what each area is.browser manifests whose program is gone. What only a guess could tie to an app stays for you to look at: a foldernamed only for a maker, such as `Google` in Application Support, a data folder only the app's documentation names,such as Tor Browser's `TorBrowser-Data`, and a hidden folder in your home named like an app, since one such as- `~/.local` is shared by many command-line tools.+ `~/.local` is shared by many command-line tools. What only an administrator can move, from a place Peel's helper+ isn't allowed to move it from, is listed apart under Needs an Administrator, with how to remove it in Finder.- **Developer:** caches of developer tools, editors, browsers, and AI models. Nothing is selected for you, and SelectRecommended passes by what you may want again; toolchains or anything holding an account are never listed.- **Build Artifacts:** what builds left in your projects, like `node_modules`, `DerivedData`, or `target`, each onlydiff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 46254556..a8ccba82 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -80737,6 +80737,112 @@}}},+ "Needs an Administrator" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Vyžaduje správce"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Benötigt einen Administrator"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Necesita un administrador"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nécessite un administrateur"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Richiede un amministratore"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "管理者が必要"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "관리자 필요"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Beheerder vereist"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Wymaga administratora"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Requer um Administrador"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Necesită un administrator"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Нужен администратор"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Kräver en administratör"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Yönetici Gerektirenler"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Потрібен адміністратор"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "需要管理员"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "需要管理者"+ }+ }+ }+ },"Needs an SSH key in ~/.ssh" : {"localizations" : {"cs" : {@@ -98427,6 +98533,218 @@}}},+ "Only an administrator can move these, and Peel’s helper isn’t allowed to move them from where they are. To remove one, show it in Finder, drag it to the Trash, then enter an administrator name and password when macOS asks." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Tyto položky může přesunout jen správce a pomocník Peelu je nesmí přesunout z místa, kde jsou. Chcete-li některou z nich odstranit, zobrazte ji ve Finderu, přetáhněte ji do koše a potom zadejte jméno a heslo správce, až o ně macOS požádá."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nur ein Administrator kann diese verschieben, und das Hilfsprogramm von Peel darf sie von dort, wo sie sind, nicht verschieben. Um eines davon zu entfernen, zeige es im Finder an, ziehe es in den Papierkorb und gib dann den Adminnamen und das Adminpasswort ein, wenn macOS danach fragt."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Solo un administrador puede trasladar estos ítems, y el asistente de Peel no tiene permiso para trasladarlos desde donde están. Para eliminar uno, muéstralo en el Finder, arrástralo a la papelera y, después, introduce un nombre de administrador y la contraseña cuando macOS te lo pida."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Seul un administrateur peut déplacer ces éléments, et l’utilitaire de Peel n’est pas autorisé à les déplacer depuis leur emplacement. Pour en supprimer un, affichez-le dans le Finder, faites-le glisser dans la corbeille, puis saisissez un nom et un mot de passe d’administrateur lorsque macOS vous le demande."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Solo un amministratore può spostare questi elementi, e all’assistente di Peel non è consentito spostarli da dove si trovano. Per rimuoverne uno, mostralo nel Finder, trascinalo nel Cestino, poi inserisci un nome e una password di amministratore quando macOS te lo chiede."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "これらを移動できるのは管理者だけで、Peelのヘルパーはこれらがある場所からの移動を許可されていません。項目を取り除くには、Finderに表示してゴミ箱にドラッグし、macOSから求められたら管理者名とパスワードを入力してください。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "관리자만 이 항목들을 이동할 수 있으며, Peel 보조 프로그램이 현재 위치에서 이 항목들을 이동하는 것은 허용되지 않습니다. 항목을 제거하려면 Finder에서 해당 항목을 보고 휴지통으로 드래그한 다음, macOS가 요청하면 관리자 이름 및 암호를 입력하십시오."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Alleen een beheerder kan deze verplaatsen, en het hulpprogramma van Peel mag ze daar niet vandaan verplaatsen. Om een onderdeel te verwijderen, toon je het in Finder, sleep je het naar de prullenmand en voer je daarna de naam en het wachtwoord van een beheerder in als macOS erom vraagt."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Przenieść te rzeczy może tylko administrator, a pomocnikowi Peel nie wolno ich przenosić z miejsc, w których się znajdują. Aby pozbyć się jednej z nich, pokaż ją w Finderze, przeciągnij do Kosza, a następnie wprowadź nazwę i hasło administratora, gdy macOS o to poprosi."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Só um administrador pode mover estes itens, e o auxiliar do Peel não tem permissão para movê-los de onde estão. Para remover um deles, mostre-o no Finder, arraste-o para o Lixo, depois insira o nome e a senha de um administrador quando o macOS pedir."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Doar un administrator poate muta aceste articole, iar instrumentul de ajutor Peel nu are voie să le mute de unde se află. Pentru a elimina unul, afișați‑l în Finder, trageți‑l în Coș, apoi introduceți un nume de administrator și o parolă când macOS vi le cere."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Переместить эти объекты может только администратор, а помощнику Peel не разрешено перемещать их оттуда, где они находятся. Чтобы удалить объект, покажите его в Finder, перетяните в Корзину, затем введите имя и пароль администратора, когда macOS их запросит."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bara en administratör kan flytta de här, och Peels hjälpprogram får inte flytta dem från deras nuvarande plats. Om du vill ta bort ett av dem visar du det i Finder, drar det till papperskorgen och anger sedan ett administratörsnamn och lösenord när macOS ber om det."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bunları yalnızca bir yönetici taşıyabilir ve Peel’in yardımcısının onları bulundukları yerden taşımasına izin verilmiyor. Bunlardan birini kaldırmak için onu Finder’da gösterin, Çöp Sepeti’ne sürükleyin, ardından macOS istediğinde bir yönetici adı ve parolası girin."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Перемістити їх може лише адміністратор, а помічнику Peel не дозволено переміщувати їх звідти, де вони лежать. Щоб вилучити один із них, покажіть його у Finder, перетягніть його в Смітник, а потім введіть імʼя й пароль адміністратора, коли macOS запитає."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "只有管理员才能移动这些项目,而Peel的帮助程序不能从其所在的位置移动它们。若要移除其中一项,请在“访达”中显示它,将它拖到废纸篓,然后在macOS要求时输入管理员名称和密码。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "只有管理者能移動這些項目,而Peel的輔助程式不能從所在位置移動它們。若要移除其中一個項目,請將它顯示於Finder並拖到「垃圾桶」,然後在macOS要求時輸入管理者名稱和密碼。"+ }+ }+ }+ },+ "Only an administrator can remove these" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Tyto položky může odstranit jen správce"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nur ein Administrator kann diese entfernen"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Solo un administrador puede eliminar estos ítems"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Seul un administrateur peut supprimer ces éléments"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Solo un amministratore può rimuoverli"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "これらを取り除けるのは管理者だけです"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "관리자만 이 항목들을 제거할 수 있음"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Alleen een beheerder kan deze verwijderen"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Przenieść je do Kosza może tylko administrator"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Só um administrador pode remover estes itens"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Doar un administrator le poate elimina"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Удалить эти объекты может только администратор"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bara en administratör kan ta bort de här"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bunları yalnızca bir yönetici kaldırabilir"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Вилучити їх може лише адміністратор"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "只有管理员才能移除这些项目"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "只有管理者能移除這些項目"+ }+ }+ }+ },"Only an administrator can use Peel’s helper, so Peel can’t remove these from this account." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swiftindex b9e8ea5d..b27822d2 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift@@ -6,7 +6,7 @@ struct OrphansCommand: AsyncParsableCommand {static let configuration = CommandConfiguration(commandName: "orphans",abstract: "List files left by apps that are no longer installed, and move a group to the Trash.",- discussion: "Nothing here is ever suggested, so --remove takes the identifier of one group. What Peel refuses to move, what it leaves for you to choose in the app, and what needs administrator access, stays."+ discussion: "Nothing here is ever suggested, so --remove takes the identifier of one group. What Peel refuses to move, what it leaves for you to choose in the app, and what needs administrator access, stays. What only an administrator can move is listed apart, with how to remove it in Finder.")@Argument(help: "The group to move, as `peel orphans` names it in its first column.")@@ -22,8 +22,15 @@ struct OrphansCommand: AsyncParsableCommand {/// What `--json` writes.struct Report: Encodable {let groups: [Group]+ let forAnAdministrator: [ForAnAdministrator]let unreadableLocations: [String]+ struct ForAnAdministrator: Encodable {+ let path: String+ let size: MeasuredSize+ let apps: [String]+ }+struct Group: Encodable {let identifier: Stringlet size: MeasuredSize@@ -94,30 +101,35 @@ struct OrphansCommand: AsyncParsableCommand {if output.json {try Output.json(Self.report(for: scan))- } else if scan.groups.isEmpty {+ } else if scan.groups.isEmpty, scan.forAnAdministrator.isEmpty {Output.line("No orphaned files found.")} else {for group in scan.groups {Output.line(Self.heading(for: group))Output.table(Self.rows(for: group), indent: " ")}+ if !scan.forAnAdministrator.isEmpty {+ Output.line(Self.administratorHeading(for: scan))+ Output.table(Self.administratorRows(for: scan), indent: " ")+ }}for note in Self.notes(for: scan) {Output.note(note)}}- /// What the list could not cover: the folders Peel could not read, and the places with more folders inside- /// than Peel looks into.+ /// What the list could not cover, the folders Peel could not read and the places with more folders inside than+ /// Peel looks into, and how to remove what only an administrator can move.static func notes(for scan: OrphanScan) -> [String] {var notes: [String] = []if !scan.unreadableLocations.isEmpty {let folders = scan.unreadableLocations.map(\.url)notes.append(Output.unreadableNote(for: folders, needsFullDiskAccess: scan.needsFullDiskAccess))}- return notes + scan.cutShortLocations.map {+ notes += scan.cutShortLocations.map {"There are more folders in \(Output.plain(Output.path($0.url))) than Peel looks inside, so an orphaned file may be in a folder Peel didn't reach."}+ return notes + (scan.forAnAdministrator.isEmpty ? [] : [byHand])}/// Why nothing is listed when some apps could not be read: their files would look orphaned.@@ -142,10 +154,29 @@ struct OrphansCommand: AsyncParsableCommand {})},+ forAnAdministrator: scan.forAnAdministrator.map { entry in+ Report.ForAnAdministrator(+ path: Output.path(entry.item.url), size: MeasuredSize(entry.item.size), apps: entry.apps+ )+ },unreadableLocations: scan.unreadableLocations.map { Output.path($0.url) })}+ /// How to remove what only an administrator can move, from a place Peel's helper may not move it from.+ static let byHand = "Only an administrator can move what Needs an administrator lists, and Peel's helper isn't allowed to move it from there. To remove one, reveal it in Finder with `open -R <path>`, drag it to the Trash, then enter an administrator name and password when macOS asks."++ static func administratorHeading(for scan: OrphanScan) -> String {+ "Needs an administrator \(Output.size(SizeTotal(scan.forAnAdministrator.map(\.item.size))))"+ }++ static func administratorRows(for scan: OrphanScan) -> [[String]] {+ scan.forAnAdministrator.map { entry in+ let apps = Output.list(entry.apps.map(Output.plain))+ return [Output.size(entry.item.size), Output.path(entry.item.url), "found for \(apps)"]+ }+ }+static func heading(for group: OrphanGroup) -> String {"\(group.identifier) \(Output.size(group.total)) \(group.confidence.levelName): \(group.confidence.summary)"}diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/AdministratorItem.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/AdministratorItem.swiftnew file mode 100644index 00000000..3647a0b6--- /dev/null+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/AdministratorItem.swift@@ -0,0 +1,11 @@+public import Foundation++/// An item only an administrator can move, from a place the helper may not move it from. Orphaned Files lists these+/// apart, with how to remove them by hand.+public struct AdministratorItem: Sendable, Hashable, Identifiable {+ public let item: OrphanItem+ /// The apps it was found for, by name.+ public let apps: [String]++ public var id: URL { item.url }+}diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swiftindex 71166692..c86221ac 100644--- a/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift@@ -20,6 +20,9 @@ public struct OrphanItem: Sendable, Hashable, Identifiable {public var installedFor: String?/// For a folder the gone app's own product file named for its data, that folder.public var productFolder: ProductFolder?+ /// True when only an administrator can move it, from a place the helper may not move it from, and nothing else+ /// holds it back.+ public var isLeftForAnAdministrator = false/// Why the item cannot be selected at all: `RemovalGuard` or the helper would refuse it.public var leftAlone: HoldBack? {@@ -100,12 +103,15 @@ public struct OrphanScan: Sendable {/// The places with more folders inside than Peel looks into (`NestedSearch.folderLimit`), so an orphaned file/// may be in one it did not reach.public var cutShortLocations: [SearchLocation] = []+ /// What only an administrator can move, listed apart from the groups.+ public var forAnAdministrator: [AdministratorItem] = []/// The same scan without the group `id`, as when the person said it belongs to an app.public func without(_ id: OrphanGroup.ID) -> OrphanScan {OrphanScan(groups: groups.filter { $0.id != id }, unreadableLocations: unreadableLocations,- needsFullDiskAccess: needsFullDiskAccess, cutShortLocations: cutShortLocations+ needsFullDiskAccess: needsFullDiskAccess, cutShortLocations: cutShortLocations,+ forAnAdministrator: forAnAdministrator)}}diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swiftindex a396809d..aa0591b0 100644--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift@@ -162,6 +162,7 @@ public struct OrphanScanner: Sendable {return (entry.identifier, item)}guard item.requiresPrivileges, item.leftAlone == nil, reach.isBeyond(item.url) else { return entry }+ item.isLeftForAnAdministrator = item.heldBack == nilitem.heldBack = .beyondTheHelperreturn (entry.identifier, item)}@@ -169,14 +170,48 @@ public struct OrphanScanner: Sendable {let byPath: (SearchLocation, SearchLocation) -> Bool = {$0.url.path(percentEncoded: false) < $1.url.path(percentEncoded: false)}+ let (groups, apart) = Self.settingApart(+ Self.group(kept, remembered: gone, installedTeams: teams, running: running)+ )return OrphanScan(- groups: Self.group(kept, remembered: gone, installedTeams: teams, running: running),+ groups: groups,unreadableLocations: unreadableLocations.sorted(by: byPath),needsFullDiskAccess: unreadableLocations.contains { FullDiskAccess.canList($0.url) == .missing },- cutShortLocations: cutShortLocations.sorted(by: byPath)+ cutShortLocations: cutShortLocations.sorted(by: byPath),+ forAnAdministrator: apart)}+ /// Takes out of `groups` what only an administrator can move, each with the app it was found for. A group Peel is+ /// unsure of keeps its own, since something may still use them, and a group left empty goes.+ static func settingApart(_ groups: [OrphanGroup]) -> (groups: [OrphanGroup], apart: [AdministratorItem]) {+ var apart: [AdministratorItem] = []+ let kept = groups.compactMap { group -> OrphanGroup? in+ guard group.confidence.level != .unsure else { return group }+ let (leaving, staying) = (+ group.items.filter(\.isLeftForAnAdministrator), group.items.filter { !$0.isLeftForAnAdministrator }+ )+ guard !leaving.isEmpty else { return group }+ apart += leaving.map { AdministratorItem(item: $0, apps: [group.title]) }+ guard !staying.isEmpty else { return nil }+ return OrphanGroup(+ identifier: group.identifier,+ items: staying,+ rememberedApp: group.rememberedApp,+ confidence: group.confidence+ )+ }+ return (kept, apart.sorted { comesBefore($0.item, $1.item) })+ }++ /// The order a list of orphaned items keeps: the largest first, what could not be measured before all, then by+ /// path.+ static func comesBefore(_ one: OrphanItem, _ other: OrphanItem) -> Bool {+ one.size != other.size+ ? SizeTotal([one.size]) > SizeTotal([other.size])+ : one.url.path(percentEncoded: false) < other.url.path(percentEncoded: false)+ }+private var manifestFolders: Set<String> {let manifests = environment.locations.filter { $0.kind == .nativeMessagingHosts }return Set(manifests.map { PathPattern.comparablePath(of: $0.url) })@@ -325,11 +360,7 @@ public struct OrphanScanner: Sendable {return grouped.map { root, entries inlet identifier = entries.map { groupingKey(for: $0.identifier) }.first { $0.lowercased() == root } ?? root- let items = entries.map(\.item).sorted {- $0.size != $1.size- ? SizeTotal([$0.size]) > SizeTotal([$1.size])- : $0.url.path(percentEncoded: false) < $1.url.path(percentEncoded: false)- }+ let items = entries.map(\.item).sorted(by: comesBefore)var group = OrphanGroup(identifier: identifier,items: items,diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swiftindex 3ef9a5f1..33b5d9ca 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift@@ -532,6 +532,24 @@ struct FileCommandTests {#expect(report["unreadableLocations"] as? [String] == ["/Users/me/Library/Containers"])}+ @Test func listsApartWhatOnlyAnAdministratorCanMove() throws {+ let directory = try TemporaryDirectory()+ let item = try orphan("com.example.gone", in: directory, heldBack: .beyondTheHelper, requiresPrivileges: true)+ let scan = OrphanScan(+ groups: [], unreadableLocations: [], forAnAdministrator: [AdministratorItem(item: item, apps: ["Gone"])]+ )++ #expect(OrphansCommand.administratorHeading(for: scan) == "Needs an administrator 10 bytes")+ #expect(OrphansCommand.administratorRows(for: scan) == [["10 bytes", Output.path(item.url), "found for Gone"]])+ #expect(OrphansCommand.notes(for: scan) == [OrphansCommand.byHand])+ let json = try Output.jsonText(OrphansCommand.report(for: scan))+ let report = try #require(JSONSerialization.jsonObject(with: Data(json.utf8)) as? [String: Any])+ let listed = try #require(report["forAnAdministrator"] as? [[String: Any]])+ #expect(listed.first?["path"] as? String == Output.path(item.url))+ #expect(listed.first?["size"] as? Int == 10)+ #expect(listed.first?["apps"] as? [String] == ["Gone"])+ }+@Test func theOrphansListSaysWhereItStoppedLookingInsideFolders() {let caches = SearchLocation(kind: .caches, url: URL(filePath: "/Users/me/Library/Caches", directoryHint: .isDirectory))var scan = OrphanScan(groups: [], unreadableLocations: [caches], needsFullDiskAccess: true)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swiftindex 803cd4a7..f67a6f30 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift@@ -363,6 +363,49 @@ struct OrphanScannerTests {#expect(try item(beyond).leftAlone == .beyondTheHelper)}+ @Test(.permissionsHold) func whatOnlyAnAdministratorCanMoveIsListedApart() async throws {+ let directory = try TemporaryDirectory()+ let beyond = try directory.directory("root/Library/com.gone.app")+ let served = try directory.directory("root/Library/Application Support/com.gone.app")+ let own = try directory.directory("home/Library/Caches/com.gone.app")+ let alone = try directory.directory("root/Library/com.gone.solo")+ let coin = try directory.directory("root/Library/com.gone.coin")+ try directory.file("root/Library/com.gone.coin/wallet.dat")+ let busy = try directory.directory("root/Library/com.gone.busy")+ let locked = [beyond, served, alone, coin, busy]+ for folder in locked {+ try directory.setPermissions(0o555, of: folder)+ }+ defer {+ for folder in locked {+ try? FileManager.default.setAttributes(+ [.posixPermissions: 0o755],+ ofItemAtPath: folder.path(percentEncoded: false)+ )+ }+ }+ let gone = ["com.gone.app", "com.gone.solo", "com.gone.coin", "com.gone.busy"].map { identifier in+ RememberedApp(+ bundleIdentifier: identifier, name: identifier.uppercased(), teamIdentifier: nil, lastSeen: .now,+ lastPath: "/Applications/\(identifier).app"+ )+ }++ let scan = await scanner(in: directory).scan(+ installedApps: installed, remembered: gone, running: ["com.gone.busy"]+ )+ let paths = { (urls: [URL]) in Set(urls.map(PathPattern.comparablePath(of:))) }+ func group(_ identifier: String) -> OrphanGroup? { scan.groups.first { $0.identifier == identifier } }++ #expect(paths(scan.forAnAdministrator.map(\.item.url)) == paths([beyond, alone]))+ #expect(scan.forAnAdministrator.first { $0.item.url.lastPathComponent == "com.gone.app" }?.apps == ["COM.GONE.APP"])+ #expect(scan.forAnAdministrator.allSatisfy { $0.item.leftAlone == .beyondTheHelper })+ #expect(paths(group("com.gone.app")?.items.map(\.url) ?? []) == paths([served, own]))+ #expect(group("com.gone.solo") == nil)+ #expect(paths(group("com.gone.coin")?.items.map(\.url) ?? []) == paths([coin]))+ #expect(paths(group("com.gone.busy")?.items.map(\.url) ?? []) == paths([busy]))+ }+/// What the walk saw inside may exist nowhere else. A folder with a wallet, a signing key, or a repository/// in it says so and is moved only when chosen by hand: Select All and `peel orphans --remove` pass it by.@Test func aFolderWithAWalletOrARepositoryInsideIsChosenOnlyByHand() async throws {diff --git a/Peel/Model/FoundLastTimeStore.swift b/Peel/Model/FoundLastTimeStore.swiftindex 7ce2cb40..03c9ec99 100644--- a/Peel/Model/FoundLastTimeStore.swift+++ b/Peel/Model/FoundLastTimeStore.swift@@ -42,8 +42,9 @@ extension AppLibrary {}extension OrphanLibrary {+ /// Each row of the list counts, what only an administrator can move as one, and only what Peel can move is sized.var looked: Looked? {- scan.map { Looked(count: $0.groups.count, size: SizeTotal(combining: $0.groups.map(\.movable))) }+ scan.map { Looked(count: pages.count, size: SizeTotal(combining: $0.groups.map(\.movable))) }}}diff --git a/Peel/Model/OrphanLibrary.swift b/Peel/Model/OrphanLibrary.swiftindex b3de4bc7..85c6051c 100644--- a/Peel/Model/OrphanLibrary.swift+++ b/Peel/Model/OrphanLibrary.swift@@ -3,6 +3,12 @@ import Foundationimport Observationimport PeelCore+/// A page of Orphaned Files: what only an administrator can move, or a group.+enum OrphanPage: Hashable {+ case forAnAdministrator+ case group(OrphanGroup.ID)+}+@Observablefinal class OrphanLibrary {private(set) var scan: OrphanScan?@@ -10,7 +16,7 @@ final class OrphanLibrary {let scanRun = ScanRun()var isScanning: Bool { scanRun.isRunning }private(set) var isRemoving = false- var selection: OrphanGroup.ID?+ var selection: OrphanPage?var selectedURLs: Set<URL> = []/// The apps list the scan was checked against. The page scans again when the list changes.@@ -19,7 +25,14 @@ final class OrphanLibrary {private(set) var owners = OrphanOwners().load()var selectedGroup: OrphanGroup? {- scan?.groups.first { $0.id == selection }+ guard case .group(let id) = selection else { return nil }+ return scan?.groups.first { $0.id == id }+ }++ /// The pages the list shows, in its order.+ var pages: [OrphanPage] {+ guard let scan else { return [] }+ return (scan.forAnAdministrator.isEmpty ? [] : [.forAnAdministrator]) + scan.groups.map { .group($0.id) }}func selected(in group: OrphanGroup) -> [OrphanItem] {@@ -55,7 +68,7 @@ final class OrphanLibrary {scan = resultscannedAgainst = listingselectedURLs.formIntersection(remainingURLs)- if let selection, !result.groups.contains(where: { $0.id == selection }) {+ if let selection, !pages.contains(selection) {self.selection = nil}}@@ -68,7 +81,7 @@ final class OrphanLibrary {owners[group.identifier.lowercased()] = identifierself.scan = scan.without(group.id)selectedURLs.subtract(group.items.map(\.url))- if selection == group.id { selection = nil }+ if selection == .group(group.id) { selection = nil }}/// Lists `groups` again, forgetting the app each was given to.@@ -117,6 +130,6 @@ extension OrphanLibrary: CarriesSelection {}func choose(_ page: CarriedSelection.Page) {- selection = page.scope+ selection = .group(page.scope)}}diff --git a/Peel/Views/ContentView.swift b/Peel/Views/ContentView.swiftindex f2f3abe7..79c9a241 100644--- a/Peel/Views/ContentView.swift+++ b/Peel/Views/ContentView.swift@@ -523,7 +523,9 @@ struct ContentView: View {@ViewBuilderprivate var orphanDetail: some View {- if let group = orphans.selectedGroup {+ if orphans.selection == .forAnAdministrator, let items = orphans.scan?.forAnAdministrator, !items.isEmpty {+ AdministratorItemsView(items: items)+ } else if let group = orphans.selectedGroup {OrphanDetailView(group: group).id(group.id)} else {diff --git a/Peel/Views/Orphans/AdministratorItemsView.swift b/Peel/Views/Orphans/AdministratorItemsView.swiftnew file mode 100644index 00000000..ab0f4352--- /dev/null+++ b/Peel/Views/Orphans/AdministratorItemsView.swift@@ -0,0 +1,69 @@+import AppKit+import PeelCore+import SwiftUI++/// What only an administrator can move, from places Peel's helper may not move it from, and how to remove it by hand.+struct AdministratorItemsView: View {+ @Environment(OrphanLibrary.self) private var orphans+ let items: [AdministratorItem]++ var body: some View {+ List {+ header+ .listRowSeparator(.hidden)++ if orphans.scan?.needsFullDiskAccess == true {+ FullDiskAccessBanner()+ } else if let unreadable = orphans.scan?.unreadableLocations, !unreadable.isEmpty {+ UnreadableFoldersNotice(folders: unreadable.map(\.url))+ }++ Section {+ RemovalColumnHeaders(hasNoteColumn: true)+ ForEach(Array(items.enumerated()), id: \.element.id) { index, entry in+ RemovalRow(+ url: entry.item.url,+ icon: .symbol(entry.item.kind.symbolName),+ detail: nil,+ kind: entry.item.kind.title,+ warning: String(localized: HoldBack.beyondTheHelper.explanation),+ lastWritten: entry.item.modificationDate,+ foundFor: entry.apps.formatted(.list(type: .and)),+ size: entry.item.size ?? 0,+ isMeasured: entry.item.size != nil,+ isLeftAlone: true,+ isFirst: index == 0,+ selection: orphans, isSelected: false+ )+ }+ .listRowSeparator(.hidden)+ } header: {+ SectionHeaderLine {+ Text("Files")+ } actions: {+ EmptyView()+ }+ }+ }+ .scrollBarBelowSectionHeaders()+ .dimmedWhileBusy(orphans.isScanning)+ .fadesInColumn(whenRowsChange: items.map(\.id))+ .navigationTitle(Text("Needs an Administrator"))+ .toolbar(removing: .title)+ }++ private var header: some View {+ PageHeader(systemImage: "lock.shield") {+ Text("Needs an Administrator")+ .pageHeading()+ } details: {+ Text("Only an administrator can move these, and Peel’s helper isn’t allowed to move them from where they are. To remove one, show it in Finder, drag it to the Trash, then enter an administrator name and password when macOS asks.")+ .font(.callout)+ .foregroundStyle(.secondary)+ .fixedSize(horizontal: false, vertical: true)+ Button("Show in Finder", systemImage: "folder") {+ NSWorkspace.shared.activateFileViewerSelecting(items.map(\.item.url))+ }+ }+ }+}diff --git a/Peel/Views/Orphans/OrphanList.swift b/Peel/Views/Orphans/OrphanList.swiftindex e1a92136..d7137943 100644--- a/Peel/Views/Orphans/OrphanList.swift+++ b/Peel/Views/Orphans/OrphanList.swift@@ -12,13 +12,22 @@ struct OrphanList: View {var body: some View {@Bindable var orphans = orphanslet filtered = filteredGroups+ let forAnAdministrator = filteredForAnAdministrator- List(filtered, selection: $orphans.selection) { group in- OrphanGroupRow(group: group)+ List(selection: $orphans.selection) {+ if !forAnAdministrator.isEmpty {+ AdministratorRow(items: forAnAdministrator)+ .tag(OrphanPage.forAnAdministrator)+ }+ ForEach(filtered) { group in+ OrphanGroupRow(group: group)+ .tag(OrphanPage.group(group.id))+ }}.accessibilityLabel(Text(Tool.orphans.title))- .contextMenu(forSelectionType: OrphanGroup.ID.self) { ids in- if ids.count == 1, let group = filtered.first(where: { ids.contains($0.id) }) {+ .contextMenu(forSelectionType: OrphanPage.self) { pages in+ if pages.count == 1, case .group(let id)? = pages.first,+ let group = filtered.first(where: { $0.id == id }) {Menu("This Belongs To") {// What a group belongs to is kept by the app's identifier.let apps = library.apps.filter { $0.bundleIdentifier != nil }@@ -29,7 +38,7 @@ struct OrphanList: View {}}}- .scanState(phase(filtered), isRescanning: isRescanning, scan: orphans.scanRun) {+ .scanState(phase(filtered, forAnAdministrator), isRescanning: isRescanning, scan: orphans.scanRun) {if !library.unreadable.isEmpty {ContentUnavailableView {Label("Not Every App Could Be Read", systemImage: "exclamationmark.triangle")@@ -46,8 +55,7 @@ struct OrphanList: View {Button("Open System Settings") { home.openFullDiskAccessSettings() }}}- } else if orphans.scan?.groups.isEmpty == true, let unreadable = orphans.scan?.unreadableLocations,- !unreadable.isEmpty {+ } else if listsNothing, let unreadable = orphans.scan?.unreadableLocations, !unreadable.isEmpty {ContentUnavailableView {Label("Not Everything Could Be Read", systemImage: "exclamationmark.triangle")} description: {@@ -61,7 +69,7 @@ struct OrphanList: View {Button("Open System Settings") { home.openFullDiskAccessSettings() }}}- } else if orphans.scan?.groups.isEmpty == true {+ } else if listsNothing {ContentUnavailableView("No Orphaned Files",systemImage: "checkmark.seal",@@ -84,8 +92,8 @@ struct OrphanList: View {}.motion(.settle, .movement, value: orphans.scan?.cutShortLocations.isEmpty == false)}- .columnSearch(text: $searchText, prompt: "Search Orphaned Files", when: orphans.scan?.groups.isEmpty == false)- .fadesInColumn(whenRowsChange: orphans.scan?.groups.map(\.id))+ .columnSearch(text: $searchText, prompt: "Search Orphaned Files", when: orphans.scan != nil && !listsNothing)+ .fadesInColumn(whenRowsChange: orphans.pages).navigationTitle(Text(Tool.orphans.title)).announcesScan(orphans.isScanning,@@ -126,14 +134,19 @@ struct OrphanList: View {.rescanOnExclusionChange("OrphanList") { await orphans.refresh(from: library) }}- private func phase(_ filtered: [OrphanGroup]) -> ScanPhase {+ private func phase(_ filtered: [OrphanGroup], _ forAnAdministrator: [AdministratorItem]) -> ScanPhase {if !library.unreadable.isEmpty { return .message }if orphans.scan == nil { return orphans.scanRun.wasStopped ? .stopped : .scanning(.walk) }- if orphans.scan?.groups.isEmpty == true { return .message }- if filtered.isEmpty, !searchText.isEmpty { return .message }+ if listsNothing { return .message }+ if filtered.isEmpty, forAnAdministrator.isEmpty, !searchText.isEmpty { return .message }return .content}+ /// True once a scan found nothing at all to list, before any search.+ private var listsNothing: Bool {+ orphans.scan.map { $0.groups.isEmpty && $0.forAnAdministrator.isEmpty } ?? false+ }+private var filteredGroups: [OrphanGroup] {let groups = orphans.scan?.groups ?? []guard !searchText.isEmpty else { return groups }@@ -141,6 +154,41 @@ struct OrphanList: View {SearchText.matches($0.identifier, searchText) || SearchText.matches($0.title, searchText)}}++ /// What only an administrator can move, all of it while the search names its row, and otherwise the items whose+ /// path or app the search names.+ private var filteredForAnAdministrator: [AdministratorItem] {+ let items = orphans.scan?.forAnAdministrator ?? []+ guard !searchText.isEmpty, !SearchText.matches(String(localized: AdministratorRow.title), searchText) else {+ return items+ }+ return items.filter { item in+ SearchText.matches(item.item.url.path(percentEncoded: false), searchText)+ || item.apps.contains { SearchText.matches($0, searchText) }+ }+ }+}++/// The row of what only an administrator can move, first in the list.+private struct AdministratorRow: View {+ static let title: LocalizedStringResource = "Needs an Administrator"+ let items: [AdministratorItem]++ var body: some View {+ HStack(spacing: 6) {+ VStack(alignment: .leading, spacing: 2) {+ Text(Self.title)+ .lineLimit(1)+ Text("Only an administrator can remove these")+ .font(.caption)+ .foregroundStyle(.secondary)+ }+ Spacer(minLength: 6)+ Text(SizeTotal(items.map(\.item.size)).text)+ .rowFigure()+ }+ .padding(.vertical, 2)+ }}private struct OrphanGroupRow: View {diff --git a/Support/peel.1 b/Support/peel.1index e5cfb692..60ad36b8 100644--- a/Support/peel.1+++ b/Support/peel.1@@ -1,5 +1,5 @@.\" "Generated by swift-argument-parser"-.Dd October 7, 2026+.Dd October 13, 2026.Dt PEEL 1.Os.Sh NAME@@ -94,7 +94,7 @@ Show help information..It Em orphansList files left by apps that are no longer installed, and move a group to the Trash..Pp-Nothing here is ever suggested, so --remove takes the identifier of one group. What Peel refuses to move, what it leaves for you to choose in the app, and what needs administrator access, stays.+Nothing here is ever suggested, so --remove takes the identifier of one group. What Peel refuses to move, what it leaves for you to choose in the app, and what needs administrator access, stays. What only an administrator can move is listed apart, with how to remove it in Finder..Bl -tag -width 6n.It Ar groupThe group to move, as `peel orphans` names it in its first column.