MCPcopy
hub / github.com/wshobson/agents / emit_plugin

Method emit_plugin

tools/adapters/codex.py:346–386  ·  view source on GitHub ↗
(self, plugin: PluginSource)

Source from the content-addressed store, hash-verified

344 self.repo_root = repo_root if repo_root is not None else WORKTREE
345
346 def emit_plugin(self, plugin: PluginSource) -> EmitResult:
347 result = EmitResult()
348
349 # Detect skill/command name collisions before emitting — Codex maps both into
350 # `.codex/skills/<plugin>__<name>/`, so duplicates would silently overwrite.
351 skill_names = {s.name for s in plugin.skills}
352 command_collisions = {c.name for c in plugin.commands} & skill_names
353
354 # Second-order collision: if a skill is literally named `<x>__command`, the
355 # `__command` suffix the adapter uses for collision-resolution would clash
356 # with it. Detect and route the command-skill to `__cmd` instead.
357 skill_suffix_conflicts: set[str] = set()
358 for cmd_name in command_collisions:
359 if f"{cmd_name}__command" in skill_names:
360 skill_suffix_conflicts.add(cmd_name)
361 result.warnings.append(
362 f"plugin `{plugin.name}` has skill `{cmd_name}`, command `{cmd_name}`, "
363 f"AND skill `{cmd_name}__command` — command-skill routed to "
364 f"`{cmd_name}__cmd` to avoid second-order collision"
365 )
366
367 for skill in plugin.skills:
368 self._emit_skill(plugin, skill, result)
369 for agent in plugin.agents:
370 self._emit_agent(plugin, agent, result)
371 # Codex deprecated prompts in favor of skills. Synthesize a skill from each command.
372 for cmd in plugin.commands:
373 collides = cmd.name in command_collisions
374 suffix_conflict = cmd.name in skill_suffix_conflicts
375 self._emit_command_as_skill(
376 plugin,
377 cmd,
378 result,
379 collides=collides,
380 fallback_suffix=suffix_conflict,
381 )
382
383 # Per-plugin Codex manifest for native marketplace install (reads source skills).
384 self._emit_codex_plugin_manifest(plugin, result)
385
386 return result
387
388 def emit_global(self, plugins: list[PluginSource]) -> EmitResult:
389 """Validate the committed root AGENTS.md and emit the Codex marketplace registry.

Calls 6

_emit_skillMethod · 0.95
_emit_agentMethod · 0.95
EmitResultClass · 0.90
addMethod · 0.45