refactor(run): extract 4 helpers from 243-line cmdRunHeadless#3345
Open
refactor(run): extract 4 helpers from 243-line cmdRunHeadless#3345
Conversation
Break cmdRunHeadless into focused, independently testable phases: - validateHeadlessInputs: input validation + manifest loading + entity checks - fetchAndRunWindows: Windows bundle download + execution path - fetchAndRunUnix: macOS/Linux script download + execution path - extractConnectionFields: post-run record lookup + field validation cmdRunHeadless is now ~30 lines of orchestration. Agent: complexity-hunter Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why:
cmdRunHeadless(243 lines) mixed input validation, platform-specific script fetching, and post-run record extraction into a single monolith. Extracting these into focused helpers makes each phase independently testable and reduces the orchestrator to ~30 lines.Changes
Extracted 4 helpers from
cmdRunHeadlessinpackages/cli/src/commands/run.ts:validateHeadlessInputs— input validation, manifest loading, name resolution, entity + credential checksfetchAndRunWindows— Windows bundle download (local or remote) + bun executionfetchAndRunUnix— macOS/Linux script download (CDN → GitHub fallback) + shell executionextractConnectionFields— post-run history lookup with per-field validationcmdRunHeadlessis now a thin orchestrator: validate → run (platform branch) → extract fields → output.Also bumps CLI version 1.0.20 → 1.0.21.
Test plan
bunx @biomejs/biome check src/— 0 errorsbun test— 2106 pass (2 pre-existing flaky failures unrelated to this change)bun test src/__tests__/headless*.test.ts src/__tests__/cmd-run*.test.ts— 31 pass, 0 fail-- refactor/complexity-hunter