Appendix P: NightGard Library Commander (Shop Manual)

Status: v1.0 pre-release. In development; must reach Mac App Store before book release per project memory. Sandboxed for Mac App Store distribution — the sandboxing is load-bearing and is not to be removed. GPL v3. Locked as CryoTunes companion supplemental in the book's appendix slot. Public repo at github.com/fluhartyml/NightGard-Library-Commander. NightGard Library Commander is a Mac-only Apple Music library organization tool for users whose library has grown messy over the years — missing metadata, orphan playlists, uploaded-but-unmatched tracks, broken cloud status. The app cleans at the library level (MusicKit + AppleScript-on-macOS), never by moving physical audio files. Its sibling NightGard Commander handles the file-level work.

What it is

The project's reference audit at start named the problem precisely: 27,255 tracks across 45 playlists; 5,460 missing artist; 8,428 missing album; 7,226 missing genre; 11,247 matched; 3,122 subscription; 969 purchased; 6,651 uploaded; ~5,250 in problem cloud status. A long-tenured iCloud Music Library accumulates that kind of state, and Apple Music's own UI doesn't expose enough bulk tools to fix it. Library Commander is the bulk tool.

v1.0 ships four panes:

  1. Playlists. List all user playlists, multi-select, bulk delete, rename in place, group into folders where supported.
  2. Library. Filter to uploaded + problem-state tracks (the two pools that benefit from cleanup), per-row catalog search to find canonical Apple Music versions, one-tap replace.
  3. Playlist Locker. Backup all playlists to dated folders in iCloud Documents, list existing backups, restore from M3U, delete backups.
  4. Stats. Live library-health dashboard — tracks, playlists, missing fields, cloud status distribution.

Architecture overview

Mac SwiftUI app, sandboxed, with two service layers:

Scope rules (the DRM line)

Library Commander touches only the parts of an Apple Music library that are safely mutable:

It does not touch:

The DRM line is conservative on purpose. Touching purchased or subscription tracks risks corrupting the user's library or running afoul of licensing; the app stays in the lane where edits are unambiguously safe.

The Playlist Locker

The Locker is the lowest-risk feature in the app: it never modifies the user's playlists, only snapshots them. Backups go to a dated folder in iCloud Documents (the app declares the iCloud Documents capability in its entitlements). Each backup is a set of .m3u files — one per playlist — with the canonical track identifiers preserved. Restore reads the M3U files back and recreates the playlists with the tracks in the same order.

Locker code is ported from an earlier project (TngrnGrvWr) and stripped to Apple-Music-only behavior. Cross-platform / non-Apple-Music sources aren't supported in v1.0.

The MusicKit + AppleScript split

Library Commander uses two Apple-provided surfaces because neither one alone covers the job:

LibraryService picks the right tool per operation. The split is invisible to the panes — they call LibraryService.deletePlaylists(_:) or LibraryService.renamePlaylist(_:to:) and the service handles which mechanism to use.

Sandbox + entitlements

The app is sandboxed for Mac App Store distribution. Per project memory the sandboxing is load-bearing and is not to be removed.

Required entitlements:

UX conventions (project-memory locked)

Several UX details are locked decisions:

These aren't preferences — they're locked. Future revisions don't drift on window size, font floor, or the custom button styling.

Roadmap status

v1.0 MVP scope (the four panes, 14 task items from DeveloperNotes.swift). Per project memory: no v1.1 and no slimmed iOS companion in the v1 horizon. v2.0 is the larger architectural shift — Mac-as-server + thin iOS client — covered separately when v1.0 ships and stabilizes.

Build + deployment

Known gotchas

Sources