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

Function hasRule

packages/cli/src/commands/remove.ts:222–241  ·  view source on GitHub ↗
(agentName: SetupAgent, scope: Scope)

Source from the content-addressed store, hash-verified

220}
221
222async function hasRule(agentName: SetupAgent, scope: Scope): Promise<boolean> {
223 const agent = getAgent(agentName);
224 const rule = agent.rule;
225
226 if (rule.kind === "file") {
227 const ruleDir =
228 scope === "global" ? rule.dir("global") : join(process.cwd(), rule.dir("project"));
229 return pathExists(join(ruleDir, rule.filename));
230 }
231
232 const filePath =
233 scope === "global" ? rule.file("global") : join(process.cwd(), rule.file("project"));
234
235 try {
236 const existing = await readFile(filePath, "utf-8");
237 return existing.includes(CONTEXT7_SECTION_MARKER);
238 } catch {
239 return false;
240 }
241}
242
243async function hasSkill(agentName: SetupAgent, scope: Scope, skillName: string): Promise<boolean> {
244 const agent = getAgent(agentName);

Callers 2

detectAvailableModesFunction · 0.85
hasAnyContext7ArtifactsFunction · 0.85

Calls 2

getAgentFunction · 0.85
pathExistsFunction · 0.70

Tested by

no test coverage detected