Skip to content

Add Codex CLI as a third first-class backend - #8

Open
dfrysinger wants to merge 1 commit into
mainfrom
codex-support
Open

Add Codex CLI as a third first-class backend#8
dfrysinger wants to merge 1 commit into
mainfrom
codex-support

Conversation

@dfrysinger

Copy link
Copy Markdown
Owner

Summary

Adds Codex CLI as a third first-class backend alongside Copilot and Claude Code.

  • New invocation names: co and codex-agent, dispatched by $0's basename (same multi-call pattern as ca/copilot-agent and cc/claude-agent).
  • New workspace root CODEX_WORKSPACE_BASE (default ~/Library/CloudStorage/Dropbox/codex-workspace); agents at agent-<name>/ inside it. tmux session name codex-<name> so ca alpha, cc alpha, and co alpha coexist.
  • Resume strategy mirrors the Claude backend (Codex CLI has no --session-id flag): scan ~/.codex/sessions/**/*.jsonl for a session_meta line whose cwd matches $DIR. If found, launch codex resume --last; else fresh codex. resume --last already filters by cwd, so we only need a boolean check. rg when available (~350ms across ~1000 sessions), grep -rl fallback otherwise.
  • ALLOW_ALL=true appends --dangerously-bypass-approvals-and-sandbox — Codex's analogue of Copilot's --allow-all and Claude's --dangerously-skip-permissions.
  • install.sh: new --codex-workspace-base flag, uses the same _resolve_workspace_base helper as the other two, symlinks codex-agent + co with the same collision guard, writes CODEX_WORKSPACE_BASE into the config, reports codex --version in backend detection.
  • uninstall.sh: removes co / codex-agent symlinks with the existing exact-match guard.
  • README.md: updates the intro, "What you get", installer summary, first-launch, workspace-locations, config, and roadmap sections to reflect Codex as a shipped backend rather than a future one.

Test plan

Verified against Codex CLI 0.145.0 + Copilot CLI 1.0.72 + Claude Code on macOS Tahoe (Apple silicon), by shim-mocking tmux so the wrapper prints the launch string it would exec:

  • co newname (no prior sessions) → codex --dangerously-bypass-approvals-and-sandbox in tmux codex-newname, cwd $CODEX_WORKSPACE_BASE/agent-newname.
  • co charlie pointed at a workspace root where ~/.codex/sessions has a matching cwdcodex resume --last --dangerously-bypass-approvals-and-sandbox (resume path fires when it should).
  • co --help shows codex-specific example; env-var help lists CODEX_WORKSPACE_BASE and CODEX_BIN.
  • ca alpha and cc alpha unchanged after the refactor (regression check).
  • bash -n on bin/agent, install.sh, uninstall.sh.
  • Full end-to-end install.sh run (not exercised in this branch; local machine already had a config file, so _read_config_var CODEX_WORKSPACE_BASE path is the one that needs eyes on real install).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vcoo7Cep2YqRhgDWAg6pNd

Extends the multi-call wrapper so `co <name>` / `codex-agent <name>`
launches Codex CLI alongside the existing `ca` (Copilot) and `cc`
(Claude Code) commands. Same shape as the other two: its own
workspace root (CODEX_WORKSPACE_BASE, default
~/Library/CloudStorage/Dropbox/codex-workspace), agent-<name>/
subdirs, and a `codex-<name>` tmux session prefix so `ca alpha`,
`cc alpha`, and `co alpha` coexist on one tmux server.

Resume strategy mirrors the Claude backend since Codex CLI has no
session-id flag: if any rollout under ~/.codex/sessions has a
session_meta line whose cwd matches $DIR, launch with
`codex resume --last`; otherwise fresh `codex`. `resume --last`
already filters by cwd, so we only need a boolean "has this agent
run before" check. Scan uses ripgrep when available (~350ms across
~1000 sessions here) and falls back to `grep -rl` when it isn't.

`ALLOW_ALL=true` appends `--dangerously-bypass-approvals-and-sandbox`,
Codex's analogue of Copilot's `--allow-all` and Claude's
`--dangerously-skip-permissions`.

install.sh gains `--codex-workspace-base`, prompts for the codex
root via the same _resolve_workspace_base helper, symlinks
`codex-agent` and `co` alongside the existing four names, writes
CODEX_WORKSPACE_BASE into the config, and reports `codex --version`
in the backend-CLI detection block. uninstall.sh removes the new
symlinks with the same exact-match collision guard.

README rewrites the intro, "What you get", installer summary,
first-launch, workspace-locations, config, and roadmap sections to
name Codex as a third backend rather than a future one.
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.

1 participant