(
clack: typeof import('@clack/prompts'),
opts: RunInstallerOptions,
location: Location,
useDefaults: boolean,
)
| 598 | } |
| 599 | |
| 600 | async function resolveTargets( |
| 601 | clack: typeof import('@clack/prompts'), |
| 602 | opts: RunInstallerOptions, |
| 603 | location: Location, |
| 604 | useDefaults: boolean, |
| 605 | ): Promise<AgentTarget[]> { |
| 606 | // Explicit --target flag wins. |
| 607 | if (opts.target !== undefined) { |
| 608 | return resolveTargetFlag(opts.target, location); |
| 609 | } |
| 610 | |
| 611 | // --yes implies auto-detect. |
| 612 | if (useDefaults) { |
| 613 | return resolveTargetFlag('auto', location); |
| 614 | } |
| 615 | |
| 616 | // Interactive multi-select. |
| 617 | const detected = detectAll(location); |
| 618 | const initialValues = detected |
| 619 | .filter(({ detection }) => detection.installed) |
| 620 | .map(({ target }) => target.id); |
| 621 | // If nothing detected, default to Claude alone (matches the |
| 622 | // historical default and the smallest-surprise outcome). |
| 623 | const initial = initialValues.length > 0 ? initialValues : ['claude']; |
| 624 | |
| 625 | const choice = await clack.multiselect<string>({ |
| 626 | message: 'Which agents should CodeGraph configure?', |
| 627 | options: ALL_TARGETS.map((t) => { |
| 628 | const det = detected.find(({ target }) => target.id === t.id)!.detection; |
| 629 | const flag = det.installed ? '(detected)' : '(not found)'; |
| 630 | const globalOnly = !t.supportsLocation('local') ? ' — global only' : ''; |
| 631 | return { |
| 632 | value: t.id, |
| 633 | label: `${t.displayName} ${flag}${globalOnly}`, |
| 634 | }; |
| 635 | }), |
| 636 | initialValues: initial, |
| 637 | required: false, |
| 638 | }); |
| 639 | |
| 640 | if (clack.isCancel(choice)) { |
| 641 | clack.cancel('Installation cancelled.'); |
| 642 | process.exit(0); |
| 643 | } |
| 644 | |
| 645 | return choice |
| 646 | .map((id) => getTarget(id)) |
| 647 | .filter((t): t is AgentTarget => t !== undefined); |
| 648 | } |
| 649 | |
| 650 | |
| 651 | /** |
no test coverage detected