refactor: split cli.ts into focused modules#2498
Conversation
Extract domain/IP utilities to src/domain-utils.ts, API proxy config logic to src/api-proxy-config.ts, and input parsers to src/option-parsers.ts. The main cli.ts retains Commander setup and action handlers only. Closes #2472 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors the CLI by moving parsing/validation helpers out of src/cli.ts into focused modules while keeping src/cli.ts as the main orchestration entrypoint and re-export surface.
Changes:
- Extracted domain and agent-image helpers into
src/domain-utils.ts. - Extracted API proxy validation/domain-resolution helpers into
src/api-proxy-config.ts. - Extracted CLI option parsing/validation helpers into
src/option-parsers.ts, withsrc/cli.tsre-exporting the moved symbols for compatibility.
Findings:
src/option-parsers.ts:1introduces an unused top-levelfsimport whileparseVolumeMountsstill does its ownrequire('fs'); this will fail the repo’s ESLint configuration because@typescript-eslint/no-unused-varsis enforced as an error forsrc/**/*.ts.
Show a summary per file
| File | Description |
|---|---|
src/option-parsers.ts |
New module containing CLI flag parsing, validation, shell escaping, and mount/env parsing helpers. |
src/domain-utils.ts |
New module containing domain parsing, IP validation, agent image validation, and default API target constants. |
src/cli.ts |
Reduced main CLI module that now re-exports extracted helpers and imports the moved functions for local use. |
src/api-proxy-config.ts |
New module containing API proxy validation, warning helpers, and GHEC/GHES/API-target allowlist resolution logic. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 1
| @@ -0,0 +1,578 @@ | |||
| import * as fs from 'fs'; | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@copilot merge main and address the review feedback |
…to-modules Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Done. Merged main (commit
All 356 tests pass and lint reports 0 errors. |
Smoke Test: Copilot BYOK — PASS ✅
Running in BYOK offline mode ( cc @lpcox (author)
|
🔥 Smoke Test Results — PR #2498
PR: refactor: split cli.ts into focused modules — @lpcox, reviewer: Overall: PASS
|
|
Smoke Test Results: Status: PASS
|
|
refactor: extract createBaseAdapterConfig helper Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test Results
Overall: FAIL —
|
Chroot Version Comparison Results
ALL_TESTS_PASSED: false — Python and Node.js versions differ between host and chroot environment.
|
Summary
Split the 2,444-line
src/cli.tsinto 3 focused modules, reducing the main file to ~1,351 lines.src/domain-utils.tssrc/api-proxy-config.tssrc/option-parsers.tssrc/cli.tsBackwards compatibility
src/cli.tsre-exports all extracted symbols, so existing imports continue to work.Testing
Closes #2472