Shared action for `setup` and the deprecated `init` alias.
( cmdOpts: SetupCmdOpts, command: Command, deps: InitDeps, defaultAgent: AgentTarget, )
| 494 | |
| 495 | /** Shared action for `setup` and the deprecated `init` alias. */ |
| 496 | async function runSetupAction( |
| 497 | cmdOpts: SetupCmdOpts, |
| 498 | command: Command, |
| 499 | deps: InitDeps, |
| 500 | defaultAgent: AgentTarget, |
| 501 | ): Promise<void> { |
| 502 | const opts = buildSetupOptions(cmdOpts, command, defaultAgent); |
| 503 | |
| 504 | // When --yes is supplied without a key source, force isTTY=false so runInit |
| 505 | // emits exit 5 with a clear message rather than hanging on a prompt in a |
| 506 | // headless CI environment where a TTY fd happens to be open. |
| 507 | const effectiveDeps: InitDeps = { |
| 508 | ...deps, |
| 509 | ...(opts.yes && !opts.apiKey && !opts.fromEnv ? { isTTY: false } : {}), |
| 510 | }; |
| 511 | |
| 512 | await runInit(opts, effectiveDeps); |
| 513 | } |
| 514 | |
| 515 | export function createSetupCommand(deps: InitDeps = {}): Command { |
| 516 | const validTargets = Object.keys(TARGETS) as AgentTarget[]; |
no test coverage detected