MCPcopy
hub / github.com/colbymchenry/codegraph / resolveTargets

Function resolveTargets

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

Source from the content-addressed store, hash-verified

465}
466
467async function resolveTargets(
468 clack: typeof import('@clack/prompts'),
469 opts: RunInstallerOptions,
470 location: Location,
471 useDefaults: boolean,
472): Promise<AgentTarget[]> {
473 // Explicit --target flag wins.
474 if (opts.target !== undefined) {
475 return resolveTargetFlag(opts.target, location);
476 }
477
478 // --yes implies auto-detect.
479 if (useDefaults) {
480 return resolveTargetFlag('auto', location);
481 }
482
483 // Interactive multi-select.
484 const detected = detectAll(location);
485 const initialValues = detected
486 .filter(({ detection }) => detection.installed)
487 .map(({ target }) => target.id);
488 // If nothing detected, default to Claude alone (matches the
489 // historical default and the smallest-surprise outcome).
490 const initial = initialValues.length > 0 ? initialValues : ['claude'];
491
492 const choice = await clack.multiselect<string>({
493 message: 'Which agents should CodeGraph configure?',
494 options: ALL_TARGETS.map((t) => {
495 const det = detected.find(({ target }) => target.id === t.id)!.detection;
496 const flag = det.installed ? '(detected)' : '(not found)';
497 const globalOnly = !t.supportsLocation('local') ? ' — global only' : '';
498 return {
499 value: t.id,
500 label: `${t.displayName} ${flag}${globalOnly}`,
501 };
502 }),
503 initialValues: initial,
504 required: false,
505 });
506
507 if (clack.isCancel(choice)) {
508 clack.cancel('Installation cancelled.');
509 process.exit(0);
510 }
511
512 return choice
513 .map((id) => getTarget(id))
514 .filter((t): t is AgentTarget => t !== undefined);
515}
516
517
518/**

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