MCPcopy
hub / github.com/upstash/context7 / setupCliAgent

Function setupCliAgent

packages/cli/src/commands/setup.ts:447–480  ·  view source on GitHub ↗
(
  agentName: SetupAgent,
  scope: Scope,
  downloadData: { files: Array<{ path: string; content: string }> }
)

Source from the content-addressed store, hash-verified

445}
446
447async function setupCliAgent(
448 agentName: SetupAgent,
449 scope: Scope,
450 downloadData: { files: Array<{ path: string; content: string }> }
451): Promise<{ skillPath: string; skillStatus: string; rulePath: string; ruleStatus: string }> {
452 const agent = getAgent(agentName);
453
454 const skillDir =
455 scope === "global"
456 ? agent.skill.dir("global")
457 : join(process.cwd(), agent.skill.dir("project"));
458 let skillStatus: string;
459 try {
460 const files = customizeSkillFilesForAgent(agentName, "find-docs", downloadData.files);
461 await installSkillFiles("find-docs", files, skillDir);
462 skillStatus = "installed";
463 } catch (err) {
464 skillStatus = `failed: ${err instanceof Error ? err.message : String(err)}`;
465 }
466 const skillPath = join(skillDir, "find-docs");
467
468 let ruleStatus: string;
469 let rulePath: string;
470 try {
471 const result = await installRule(agentName, "cli", scope);
472 ruleStatus = result.status;
473 rulePath = result.path;
474 } catch (err) {
475 ruleStatus = `failed: ${err instanceof Error ? err.message : String(err)}`;
476 rulePath = "";
477 }
478
479 return { skillPath, skillStatus, rulePath, ruleStatus };
480}
481
482async function setupCli(options: SetupOptions): Promise<void> {
483 await resolveCliAuth(options.apiKey);

Callers 1

setupCliFunction · 0.85

Calls 4

getAgentFunction · 0.85
installSkillFilesFunction · 0.85
installRuleFunction · 0.85

Tested by

no test coverage detected