(agentName: SetupAgent, scope: Scope)
| 190 | } |
| 191 | |
| 192 | async function hasMcpConfig(agentName: SetupAgent, scope: Scope): Promise<boolean> { |
| 193 | const agent = getAgent(agentName); |
| 194 | // Agents with no project-level MCP (e.g. Antigravity) only have a global |
| 195 | // config — there's nothing to detect at project scope. |
| 196 | if (scope === "project" && agent.mcp.projectPaths.length === 0) return false; |
| 197 | const candidates = |
| 198 | scope === "global" |
| 199 | ? agent.mcp.globalPaths |
| 200 | : agent.mcp.projectPaths.map((path) => join(process.cwd(), path)); |
| 201 | const mcpPath = await resolveMcpPath(candidates); |
| 202 | |
| 203 | if (mcpPath.endsWith(".toml")) { |
| 204 | return readTomlServerExists(mcpPath, "context7"); |
| 205 | } |
| 206 | |
| 207 | let existing: Record<string, unknown>; |
| 208 | try { |
| 209 | existing = await readJsonConfig(mcpPath); |
| 210 | } catch (err) { |
| 211 | log.warn( |
| 212 | `Skipped ${mcpPath}: could not parse (${err instanceof Error ? err.message : String(err)})` |
| 213 | ); |
| 214 | return false; |
| 215 | } |
| 216 | const section = existing[agent.mcp.configKey]; |
| 217 | return ( |
| 218 | !!section && typeof section === "object" && !Array.isArray(section) && "context7" in section |
| 219 | ); |
| 220 | } |
| 221 | |
| 222 | async function hasRule(agentName: SetupAgent, scope: Scope): Promise<boolean> { |
| 223 | const agent = getAgent(agentName); |
no test coverage detected