Convert a Claude command into a Codex skill. If `collides=True` (a skill in the same plugin has the same name), the command- derived skill is emitted under a namespaced suffix ` __ __command` so it doesn't silently overwrite the real skill. If `fallback_
(
self,
plugin: PluginSource,
cmd,
result: EmitResult,
*,
collides: bool = False,
fallback_suffix: bool = False,
)
| 521 | result.written.append(self.write(rel, "\n".join(lines) + "\n")) |
| 522 | |
| 523 | def _emit_command_as_skill( |
| 524 | self, |
| 525 | plugin: PluginSource, |
| 526 | cmd, |
| 527 | result: EmitResult, |
| 528 | *, |
| 529 | collides: bool = False, |
| 530 | fallback_suffix: bool = False, |
| 531 | ) -> None: |
| 532 | """Convert a Claude command into a Codex skill. |
| 533 | |
| 534 | If `collides=True` (a skill in the same plugin has the same name), the command- |
| 535 | derived skill is emitted under a namespaced suffix `<plugin>__<name>__command` so |
| 536 | it doesn't silently overwrite the real skill. |
| 537 | |
| 538 | If `fallback_suffix=True` (a skill named `<name>__command` ALSO exists — the |
| 539 | second-order collision case), use `__cmd` instead. |
| 540 | """ |
| 541 | suffix = ("__cmd" if fallback_suffix else "__command") if collides else "" |
| 542 | skill_id = f"{plugin.name}__{cmd.name}{suffix}" |
| 543 | if collides: |
| 544 | result.warnings.append( |
| 545 | f"command `{cmd.name}` collides with skill `{cmd.name}` in `{plugin.name}`; " |
| 546 | f"emitted command-skill as `{skill_id}` to avoid overwrite" |
| 547 | ) |
| 548 | skill_dir = Path(".codex") / "skills" / skill_id |
| 549 | |
| 550 | fm = { |
| 551 | "name": skill_id, |
| 552 | "description": cmd.description or f"Command: {cmd.name} (from {plugin.name})", |
| 553 | } |
| 554 | body = _rewrite_body_for_codex(cmd.body).rstrip() + "\n" |
| 555 | head, overflow = _split_body_if_oversized(body, self.SKILL_BODY_CAP) |
| 556 | if overflow: |
| 557 | result.warnings.append( |
| 558 | f"command-skill `{skill_id}` body exceeded {self.SKILL_BODY_CAP}B; split into references/details.md" |
| 559 | ) |
| 560 | result.written.append( |
| 561 | self.write(skill_dir / "references" / "details.md", overflow.rstrip() + "\n") |
| 562 | ) |
| 563 | if cmd.argument_hint: |
| 564 | fm["metadata"] = {"argument-hint": cmd.argument_hint} |
| 565 | |
| 566 | content = _frontmatter_block(fm) + "\n\n" + head |
| 567 | result.written.append(self.write(skill_dir / "SKILL.md", content)) |
| 568 | |
| 569 | # ── Marketplace manifests (native install; reads source skills) ────────── |
| 570 |
no test coverage detected