Skip to content

✨ feat(model): add Codex CLI provider#5

Merged
kud merged 2 commits into
mainfrom
feat/codex-cli-provider
Jul 5, 2026
Merged

✨ feat(model): add Codex CLI provider#5
kud merged 2 commits into
mainfrom
feat/codex-cli-provider

Conversation

@kud

@kud kud commented Jul 5, 2026

Copy link
Copy Markdown
Owner

What & why

Adds a Codex CLI provider so ai-conventional-commit can generate commit messages via OpenAI Codex on a ChatGPT plan (no API key), alongside the existing claude / opencode / anthropic providers.

Closes #4.

Changes

  • CodexCliProvider (src/model/provider.ts) — shells out to codex exec, mirroring ClaudeCliProvider. Captures the final message via --output-last-message; runs --sandbox read-only --ephemeral so it never writes or persists a session. codex/ registered in the provider factory; default codex/gpt-5.5.
  • No --output-schema — OpenAI strict structured outputs reject the shared schema (they require additionalProperties: false on every object). Relies on the system prompt's embedded schema + extractJSON, exactly like the claude provider.
  • Shared prompt now requires a body (src/prompt.ts) for non-trivial changes, so every provider writes a description. Codex had been mirroring the repo's terse title-only style; this lifts it (and any model) to parity — permissive, still allowing an empty body for genuinely trivial commits.
  • Tests — factory routing + mock mode (test/model.test.ts); body-rule assertion (test/prompt.test.ts).

Verification

  • tsc --noEmit clean · vitest run 69/69 · eslint 0 errors
  • Dogfooded end-to-end: codex/gpt-5.5 generated this feature's own commit message, with a full multi-bullet body.

Auth note

Codex here uses the ChatGPT plan (codex login status → "Logged in using ChatGPT"), so there's no API-key requirement like the anthropic/ provider has.

kud added 2 commits July 5, 2026 12:44
- Route codex/ models from createProvider to a new CodexCliProvider in src/model/provider.ts.
- Add Codex CLI chat execution with schema-shaped output handling and mock provider support.
- Cover codex/ routing and mock-mode JSON parsing in test/model.test.ts.
- Drop `--output-schema` / `schemaPath` from `CodexCliProvider.chat()`: OpenAI strict structured outputs reject our shared schema because it lacks `additionalProperties:false` on every nested object
- Rely on the system prompt's embedded schema + "Return ONLY the JSON object" instruction, mirroring how the `claude` provider works, and let `extractJSON` parse the result
- Update error-message example model from `codex/gpt-5-codex` to `codex/gpt-5.5` in `validateModel` and align tests accordingly
- Add `Body Rules (REQUIRED for non-trivial changes)` spec line to `buildGenerationMessages` so the LLM always populates the body for feat/fix/refactor/multi-file diffs
- Minor formatting: collapse single-line arrow functions and reflow long `dbg()` call in `prompt.ts`
@kud kud merged commit fb70158 into main Jul 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Codex provider (via codex exec, plan-authed)

1 participant