Skip to content

Move the CLI commands into types that own their dependencies - #198

Merged
lynnswap merged 4 commits into
mainfrom
refactor/cli-command-types
Nov 20, 2026
Merged

lynnswap merged 4 commits into
mainfrom
refactor/cli-command-types

Conversation

@lynnswap

Copy link
Copy Markdown
Owner

Summary

The CLI's free functions become types that hold the process runner, console, and input they use. CommandLineTool parses the arguments and runs GenerateCommand, GenerationWizard, SSHGenerateCommand, SearchCommand, or DecompileCommand. Command-line syntax, output text, and exit codes do not change.

Details

  • PrivateHeaderKitCommand.swift is split by role: CommandLineTool (entry point and exit-status mapping), GenerateCommand (options and request construction), HelperPlan, SimulatorSession, and SourceDiscovery. The wizard builds a GenerateCommand for the chosen source and reuses its Simulator session and request.
  • Console pairs the standard-output and standard-error writers that every function took as two parameters.
  • Each command's parsed arguments are its nested Options. ParsedCommand(arguments:) replaces parsePrivateHeaderKitCommand.
  • PreparedGeneration now holds the executor and the prepared plan. It was a pair of closures so that tests could substitute it, which no test does since Test CLI generation through the process runner instead of per-step closures #192.
  • SSH generation takes the same resolved executable URL as the other commands. It used to fall back to CommandLine.arguments[0] on its own, which is the same value in the CLI.
  • Left as they are: raw-dump helper execution (runPrivateHeaderKitRawDump and the functions around it), rendering, terminal input, and signal coordination stay free functions, and the types in those files keep the PrivateHeaderKit prefix.
  • Tests change in how they call the entry points, with three exceptions:
    • The search tests collect output through a lock-protected recorder, because Console writers are @Sendable.
    • The decompile test for a workspace that cannot be removed makes the directory read-only instead of injecting a failing closure. It is skipped when the tests run as root, like the existing search test for an unreadable directory.
    • The SSH recovery test no longer checks that the progress event carries the whole failure text, which needed a wrapper around the prepared generation. It still checks that text in the state database and in the rendered output.

Testing

  • swift test: all six test bundles pass.
  • The full test scheme passes on the M6 mini XcodeRunnerKit host. The pull request is merged on that result and the local Codex review, without waiting for GitHub CI.
  • A Foundation dump on macOS 27.2.1 is identical to the output before this change (1,023 files).
  • --help for the root, generate, search, and decompile, and seven invalid invocations print the same text and exit with the same status as before.
  • Local Codex review: no findings.
  • Not verified locally: Simulator and SSH generation against a real device, and decompilation with a real Ghidra.

🤖 Generated with Claude Code

lynnswap and others added 4 commits November 20, 2026 10:02
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…command-types

# Conflicts:
#	Sources/PrivateHeaderKitCLI/PrivateHeaderKitSSHGeneration.swift
@lynnswap
lynnswap merged commit b713962 into main Nov 20, 2026
@lynnswap
lynnswap deleted the refactor/cli-command-types branch November 20, 2026 04:31
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 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-20T04:32:00.565053Z 6ff1335 PR opened
🔒 Security Review ✅ Completed 2026-11-20T04:32:47.834775Z 6ff1335 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.

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.

Move the CLI commands into types that own their dependencies

1 participant