MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / resolveTargets

Function resolveTargets

src/installer/index.ts:600–648  ·  view source on GitHub ↗
(
  clack: typeof import('@clack/prompts'),
  opts: RunInstallerOptions,
  location: Location,
  useDefaults: boolean,
)

Source from the content-addressed store, hash-verified

598}
599
600async 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/**

Callers 1

runInstallerWithOptionsFunction · 0.85

Calls 4

resolveTargetFlagFunction · 0.90
detectAllFunction · 0.90
getTargetFunction · 0.90
supportsLocationMethod · 0.65

Tested by

no test coverage detected