Skip to content

refactor: cut about 160 lines of pass-through layers, unused options and duplicate commands - #11

Merged
proxynico merged 1 commit into
mainfrom
refactor/simplify-audit
Nov 14, 2026
Merged

proxynico merged 1 commit into
mainfrom
refactor/simplify-audit

Conversation

@proxynico

Copy link
Copy Markdown
Owner

Nico asked for Setlist's code to carry nothing it doesn't need. An audit found layers that only pass calls through, options nothing sets, checks that can't fail, and the same logic written twice. This removes them: about 160 fewer lines of source, with the CLI and MCP server returning the same results.

What changes

  • Auto engine: the 16 playback methods each forward to the native engine in one line instead of three.
  • MCP server: createMcpServer returns the server. The tool list it also returned was never read.
  • Library audit:
    • analyzeLibrarySnapshot takes the theme-suggestion count instead of an options object, and collectLibrarySnapshot takes maxItems. The other options (topLimit, generatedAt, the 20,000 default) were never set by any caller.
    • The themes report drops a filter for empty theme lists, which can't happen.
  • Output: one listOutput factory replaces outputList and its five one-line wrappers, and one bar chart replaces the two.
  • Search: the list of search types lives in one place (SEARCH_TYPES in types.ts) instead of two.
  • API engine:
    • One number reader (optionalNum) replaces three.
    • The parameters that were only ever given one value are gone (now, and the playlist ID label), and three single-use types are inline.
  • Safari cookie parser: drops a header check readU32 already covers, an offset < 0 test on unsigned reads, a second loop, and the cookie path field nothing reads.
  • Errors: instanceof MusicError replaces isMusicError, and MusicError hands cause to the built-in Error.
  • Native engine:
    • The volume clamp is gone, since both callers already pass a whole number from 0 to 100.
    • The recovery hint is a constant instead of a function.

Two things change on purpose:

  • playlist info draws its Top Artists and Genres bars the way replay does: scaled to the largest value, with labels measured to fit.
  • playlist tracks <id> and playlist list|ls are removed. They repeated library playlist <id> and library playlists, and neither was documented.

Blast Radius

  • Anyone who types or scripts setlist playlist tracks or setlist playlist list now gets "unknown command". The fix is to use library playlist and library playlists.
  • playlist info human output looks different. Its --json and --plain output is the same.
  • Nothing is written to data, config or Keychain. Revert the commit to undo.

Verification

  • bun run check: Biome, typecheck and 87 tests pass. Two tests went with the code they tested (isMusicError on plain values, and the recovery-hint text).
  • On the Mac mini, against the real library and the signed-in API, I recorded every command's human, --json and --plain output on main and on this branch, then compared them after masking Apple's time-signed artwork links and the audit timestamp. The commands covered all three engines: status, volume, devices, config, auth status, the five search kinds, library tracks, albums and playlists, playlist info, the four audit reports, replay, and the queue and error cases.
    • All JSON and plain output matched.
    • Human output differed only in the playlist info bars and the two removed commands, which now print error: unknown command.
  • I called 16 MCP tools over stdio on main and on this branch (search, library, playlist, all four library_report reports, replay, status, devices, and two errors). The results and tools/list matched.
  • volume 37, read back, then volume 100. On a temporary playlist made for the test: playlist add, library playlist, playlist rm, and add with an unknown track (Track not found). The playlist was deleted afterwards.
  • The Safari cookie parser on main and on this branch read the real Safari cookie file the same way: 78 cookies, the same token. The developer-token finder found the same token in the live web player on both.

Created with Claude Opus 5.5 in Claude Code.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T03:32:14.845023Z 7591f76 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…mmands

The auto engine forwards playback in one line per method, and the MCP
server returns the server alone instead of a tool list nothing read.

The library audit drops options no caller sets. Search keeps one list of
search types. One list printer and one bar chart serve every command.

The Safari cookie parser drops checks that cannot fail and a field
nothing reads. The API engine keeps one number reader, and the code uses
`instanceof MusicError` and the built-in error cause directly.

Two things look different on purpose. `playlist info` draws its bars
like `replay` does. `playlist tracks` and `playlist list` are gone,
because `library playlist` and `library playlists` do the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@proxynico
proxynico force-pushed the refactor/simplify-audit branch from 7591f76 to b0a9069 Compare November 14, 2026 03:48
@proxynico

Copy link
Copy Markdown
Owner Author

Note

🤖 Claude Opus 5.5 responding on behalf of proxynico

Independent check: PASS on head b0a9069 against base f8cb512. The checker was GPT-6.1 Sol (Codex, xhigh effort), which wrote none of this change.

The first check, on 7591f76 against 704c226, compared 679 CLI and 188 MCP results across the native, API and auto engines, in human, --json and --plain output. All of them matched, apart from the two intended changes: the playlist info bars, and the removed playlist tracks and playlist list|ls. All 15 tool schemas matched too. It returned FAIL on two findings:

  • The Safari parser no longer returns each cookie's path.
  • Verbose stack traces show different source line numbers.

The re-check found neither one is a defect:

  • No code reads a cookie's path. auth import goes through readSafariToken, then the parser, then pickMediaUserToken, which uses only name, domain and value. The real Safari cookie file gave the same 78 records and the same selected token on base and head. The PR description lists the path removal.
  • Under forced network failures, messages, hints, causes and exit codes matched. Only the line numbers moved, because the files were edited.

After the rebase, git range-diff shows only the AGENTS.md test count changed (now 85). src/ is byte-identical to 7591f76, and no base commit since 704c226 touches src/. bun run check passes with 85 tests across 16 files. Spot checks on the new head (27 CLI and 15 MCP comparisons) matched.

@proxynico
proxynico merged commit cbf3551 into main Nov 14, 2026
1 check passed
@proxynico
proxynico deleted the refactor/simplify-audit branch November 14, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant