Skip to content

refactor(run): extract 4 helpers from 243-line cmdRunHeadless#3345

Open
la14-1 wants to merge 1 commit intomainfrom
refactor/extract-headless-helpers
Open

refactor(run): extract 4 helpers from 243-line cmdRunHeadless#3345
la14-1 wants to merge 1 commit intomainfrom
refactor/extract-headless-helpers

Conversation

@la14-1
Copy link
Copy Markdown
Member

@la14-1 la14-1 commented Apr 23, 2026

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 cmdRunHeadless in packages/cli/src/commands/run.ts:

  1. validateHeadlessInputs — input validation, manifest loading, name resolution, entity + credential checks
  2. fetchAndRunWindows — Windows bundle download (local or remote) + bun execution
  3. fetchAndRunUnix — macOS/Linux script download (CDN → GitHub fallback) + shell execution
  4. extractConnectionFields — post-run history lookup with per-field validation

cmdRunHeadless is 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 errors
  • bun test — 2106 pass (2 pre-existing flaky failures unrelated to this change)
  • Headless-specific tests pass: bun test src/__tests__/headless*.test.ts src/__tests__/cmd-run*.test.ts — 31 pass, 0 fail

-- refactor/complexity-hunter

@la14-1 la14-1 force-pushed the refactor/extract-headless-helpers branch from ef4a0e4 to 0dce8cd Compare April 25, 2026 08:21
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented Apr 25, 2026

Rebased onto main to resolve merge conflicts (package.json version bump).

-- refactor/pr-maintainer

@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented Apr 25, 2026

Fixed CI: removed duplicate "version" key in packages/cli/package.json that was introduced during the rebase. bun install was failing with Duplicate key "version" in object literal. CI should pass now.

-- refactor/pr-maintainer

@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented Apr 26, 2026

This PR has been open for 3+ days with all CI checks passing (ShellCheck, Mock Tests, Biome Lint, Unit Tests, macOS Compatibility — all SUCCESS). It is mergeable with no conflicts.

Requesting human review when convenient.

-- refactor/pr-maintainer

@la14-1 la14-1 force-pushed the refactor/extract-headless-helpers branch from 313806c to f405a3f Compare April 29, 2026 06:48
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented Apr 29, 2026

Rebased onto main (dropped the now-redundant duplicate-version-key fix commit). Branch is clean with 1 commit. Awaiting human review.

-- refactor/pr-maintainer

@la14-1 la14-1 force-pushed the refactor/extract-headless-helpers branch from f405a3f to 7ffc49b Compare April 30, 2026 05:08
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 3, 2026

This PR is ready for review. All CI checks pass and there are no merge conflicts.

-- refactor/pr-maintainer

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>
@la14-1 la14-1 force-pushed the refactor/extract-headless-helpers branch from 7ffc49b to 5e489bb Compare May 3, 2026 14:19
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 3, 2026

Rebased onto main (was 4 commits behind). Clean rebase, no conflicts.

-- refactor/pr-maintainer

@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 4, 2026

Verified in worktree: tests pass (2236/2238, same 2 pre-existing failures as main), lint clean (biome 0 errors). PR is mergeable and ready for review.

-- refactor/pr-maintainer

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.

2 participants