mirror of
https://github.com/github/spec-kit.git
synced 2026-07-05 13:34:06 +08:00
* Initial plan * feat: support SPECKIT_INTEGRATION_<KEY>_EXECUTABLE env var override Adds `IntegrationBase._resolve_executable()` which reads `SPECKIT_INTEGRATION_<KEY>_EXECUTABLE` (hyphens→underscores, uppercased) and falls back to `self.key` when unset or whitespace-only. All concrete `build_exec_args()` implementations now call `self._resolve_executable()` instead of hard-coding `self.key` or `"agy"` as the first argv token: - MarkdownIntegration, TomlIntegration, SkillsIntegration (base classes) - CodexIntegration, DevinIntegration, OpencodeIntegration, HermesIntegration, AgyIntegration - CopilotIntegration (overrides `_resolve_executable()` to fall back to the platform-specific `_copilot_executable()` default; also updates `dispatch_command()` to use `_resolve_executable()`) Tests added to tests/integrations/test_extra_args.py covering: - default (unset) falls back to key - env var replaces first argv token - whitespace-only env var is a no-op - key hyphen→underscore normalisation - cross-integration scoping (wrong key ignored) - all override integrations (Codex, Devin, Opencode, Copilot) - Copilot dispatch_command path - EXECUTABLE and EXTRA_ARGS can be set simultaneously See issue #2596." * fix: complete docstring sentence in _resolve_executable * test: generalize extra-args test comments for override coverage * Fix stale Codex executable comment --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
60 lines
1.7 KiB
Python
60 lines
1.7 KiB
Python
"""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",
|
|
}
|
|
context_file = "AGENTS.md"
|
|
multi_install_safe = True
|
|
|
|
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.
|
|
# 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]
|
|
self._apply_extra_args_env_var(args)
|
|
if model:
|
|
args.extend(["--model", model])
|
|
if output_json:
|
|
args.append("--json")
|
|
return args
|
|
|
|
@classmethod
|
|
def options(cls) -> list[IntegrationOption]:
|
|
return [
|
|
IntegrationOption(
|
|
"--skills",
|
|
is_flag=True,
|
|
default=True,
|
|
help="Install as agent skills (default for Codex)",
|
|
),
|
|
]
|