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

Function detectAvailableModes

packages/cli/src/commands/remove.ts:252–275  ·  view source on GitHub ↗
(agents: SetupAgent[], scope: Scope)

Source from the content-addressed store, hash-verified

250}
251
252async function detectAvailableModes(agents: SetupAgent[], scope: Scope): Promise<UninstallMode[]> {
253 let hasMcpArtifacts = false;
254 let hasCliArtifacts = false;
255 let hasRuleArtifacts = false;
256
257 for (const agent of agents) {
258 hasMcpArtifacts =
259 hasMcpArtifacts ||
260 (await hasMcpConfig(agent, scope)) ||
261 (await hasSkill(agent, scope, MODE_SKILLS.mcp[0]));
262 hasCliArtifacts = hasCliArtifacts || (await hasSkill(agent, scope, MODE_SKILLS.cli[0]));
263 hasRuleArtifacts = hasRuleArtifacts || (await hasRule(agent, scope));
264 }
265
266 const modes: UninstallMode[] = [];
267 if (hasMcpArtifacts) modes.push("mcp");
268 if (hasCliArtifacts) modes.push("cli");
269
270 if (modes.length === 0 && hasRuleArtifacts) {
271 return ["mcp", "cli"];
272 }
273
274 return modes;
275}
276
277async function hasAnyContext7Artifacts(agent: SetupAgent, scope: Scope): Promise<boolean> {
278 return (

Callers 1

resolveModesFunction · 0.85

Calls 3

hasMcpConfigFunction · 0.85
hasSkillFunction · 0.85
hasRuleFunction · 0.85

Tested by

no test coverage detected