2026-04-02 08:00:12 -05:00
|
|
|
"""Codex CLI integration — skills-based agent.
|
|
|
|
|
|
|
|
|
|
Codex uses the ``.agents/skills/speckit-<name>/SKILL.md`` layout.
|
|
|
|
|
Commands are deprecated; ``--skills`` defaults to ``True``.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from ..base import IntegrationOption, SkillsIntegration
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CodexIntegration(SkillsIntegration):
|
|
|
|
|
"""Integration for OpenAI Codex CLI."""
|
|
|
|
|
|
|
|
|
|
key = "codex"
|
|
|
|
|
config = {
|
|
|
|
|
"name": "Codex CLI",
|
|
|
|
|
"folder": ".agents/",
|
|
|
|
|
"commands_subdir": "skills",
|
|
|
|
|
"install_url": "https://github.com/openai/codex",
|
|
|
|
|
"requires_cli": True,
|
|
|
|
|
}
|
|
|
|
|
registrar_config = {
|
|
|
|
|
"dir": ".agents/skills",
|
|
|
|
|
"format": "markdown",
|
|
|
|
|
"args": "$ARGUMENTS",
|
|
|
|
|
"extension": "/SKILL.md",
|
|
|
|
|
}
|
2026-06-24 00:55:38 +09:00
|
|
|
dev_no_symlink = True
|
2026-05-01 18:54:41 +02:00
|
|
|
multi_install_safe = True
|
2026-04-02 08:00:12 -05:00
|
|
|
|
2026-07-29 06:00:26 -07:00
|
|
|
CANONICAL_TO_NATIVE = {
|
|
|
|
|
"session_start": "SessionStart",
|
|
|
|
|
"pre_tool_use": "PreToolUse",
|
|
|
|
|
"post_tool_use": "PostToolUse",
|
|
|
|
|
"session_end": "SessionEnd",
|
|
|
|
|
"user_prompt_submit": "UserPromptSubmit",
|
|
|
|
|
"stop": "Stop",
|
|
|
|
|
}
|
|
|
|
|
events_config_file = ".codex/config.toml"
|
|
|
|
|
events_format = "toml"
|
|
|
|
|
|
2026-04-14 10:11:56 -05:00
|
|
|
def build_exec_args(
|
|
|
|
|
self,
|
|
|
|
|
prompt: str,
|
|
|
|
|
*,
|
|
|
|
|
model: str | None = None,
|
|
|
|
|
output_json: bool = True,
|
|
|
|
|
) -> list[str] | None:
|
|
|
|
|
# Codex uses ``codex exec "prompt"`` for non-interactive mode.
|
2026-05-29 10:19:31 -05:00
|
|
|
# Resolve argv[0] via the shared executable resolver so operators can
|
|
|
|
|
# override the binary with SPECKIT_INTEGRATION_CODEX_EXECUTABLE.
|
|
|
|
|
args: list[str] = [self._resolve_executable(), "exec", prompt]
|
2026-05-29 02:00:15 +07:00
|
|
|
self._apply_extra_args_env_var(args)
|
2026-04-14 10:11:56 -05:00
|
|
|
if model:
|
|
|
|
|
args.extend(["--model", model])
|
|
|
|
|
if output_json:
|
|
|
|
|
args.append("--json")
|
|
|
|
|
return args
|
|
|
|
|
|
2026-04-02 08:00:12 -05:00
|
|
|
@classmethod
|
|
|
|
|
def options(cls) -> list[IntegrationOption]:
|
2026-07-29 06:00:26 -07:00
|
|
|
opts = super().options()
|
|
|
|
|
opts.append(
|
2026-04-02 08:00:12 -05:00
|
|
|
IntegrationOption(
|
|
|
|
|
"--skills",
|
|
|
|
|
is_flag=True,
|
|
|
|
|
default=True,
|
|
|
|
|
help="Install as agent skills (default for Codex)",
|
2026-07-29 06:00:26 -07:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
return opts
|