MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / mergeClaudeCodeAgentRoles

Function mergeClaudeCodeAgentRoles

src/integrations/claude-plugins.ts:206–223  ·  view source on GitHub ↗
(config: QodexConfig, cwd: string)

Source from the content-addressed store, hash-verified

204 * config roles always win over imported agents. Returns how many agents were added.
205 */
206export async function mergeClaudeCodeAgentRoles(config: QodexConfig, cwd: string): Promise<number> {
207 if (disabled()) return 0;
208 let agents: Record<string, RoleConfig>;
209 try {
210 agents = await loadClaudeCodeAgents(cwd);
211 } catch (e: any) {
212 logger.debug('mergeClaudeCodeAgentRoles failed', { err: e?.message });
213 return 0;
214 }
215 const names = Object.keys(agents);
216 if (names.length === 0) return 0;
217 const existing = ((config as any).roles ?? {}) as Record<string, RoleConfig | undefined>;
218 // Imported agents first, user config last → user wins on name collisions.
219 (config as any).roles = { ...agents, ...existing };
220 const added = names.filter(n => !existing[n]).length;
221 logger.info('Imported Claude Code agents as roles', { found: names.length, added });
222 return added;
223}
224
225// ──────────────────────── MCP servers + hooks ──────────────────────────────
226

Callers 2

Calls 4

disabledFunction · 0.85
loadClaudeCodeAgentsFunction · 0.85
debugMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected