feat: add codex-cli backend to standalone CLI (Issue #69 v1)#70
Merged
Conversation
The standalone CLI previously required a PATINA_API_KEY because every single-mode rewrite went through src/api.js (OpenAI HTTP). This adds a backend abstraction with two implementations and lets users skip the API key entirely by running rewrites through the local codex CLI, which authenticates via OpenAI/ChatGPT OAuth. Verified end-to-end on a 189-char Korean AI sample (PR #69 background): codex backend removed the canonical patterns ("~다는 점", "주목할 만", "의미 있는 교류", "지속될 것으로 전망", 격식체→평어체, 추상→구체) in ~9s with no API key. Changes: - src/backends/codex-cli.js — spawn `codex exec --skip-git-repo-check --output-last-message <tmpfile>`, pipe prompt via stdin, read result. Handles ENOENT (codex not installed), exit code, and timeout. - src/backends/index.js — registry + selectBackend() with heuristic: explicit --backend wins, then --model codex* routes to codex-cli, else openai-http (existing behavior). - src/cli.js — adds --backend and --list-backends flags, routes the single-mode rewrite path through selectBackend(). MAX (--models) and --ouroboros still go through the HTTP backend in v1; documented. - tests/e2e/backends.test.js — 12 unit tests for selection heuristic and listing. All 33 tests pass. - README.md / README_KR.md / README_JA.md / README_ZH.md — document the new backend, list-backends flag, and v1 scope (single-mode only). Refs #69. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 3, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the v1 phase of #69.
Summary
src/backends/abstraction with two implementations:openai-http(wraps existingapi.js, default) andcodex-cli(spawns localcodex exec --skip-git-repo-check --output-last-message <tmpfile>, pipes prompt via stdin).--backend <name>(explicit selection) and--list-backends(lists registered backends + availability check).selectBackend: explicit--backendwins → else--model codex*routes tocodex-cli→ elseopenai-http.--audit,--score,--diff,--ouroboros, and--models/MAX still go through the HTTP backend (documented in READMEs and the issue phasing).Verified end-to-end
Real run on a 189-char Korean AI sample (no API key, codex OAuth):
~9s wall, all canonical AI patterns removed (
~다는 점,주목할 만,의미 있는 교류,지속될 것으로 전망, 격식체→평어체, 추상→구체).Test plan
npm test— 33 / 33 pass (12 new unit tests inbackends.test.js+ 21 existing)node bin/patina.js --helpshows new flagsnode bin/patina.js --list-backendsshowsopenai-http available+codex-cli available--backend codex-cliproduces valid humanized outputOut of scope (v2+, tracked in #69)
patina doctorhealth check🤖 Generated with Claude Code