README
¶
Codex CLI adapter
What this is
This directory is the Codex CLI host adapter for Orch: a Codex plugin
that connects a Codex CLI session to the shared orch binary. It is
deliberately thin (PRD §6) — "the detailed state machine must not be
independently reimplemented in Markdown skills or platform-specific
shell scripts." Every policy decision (what is writable, what routing
applies, what a Delivery run's state is) is made by the orch binary.
This adapter only translates Codex CLI host events into calls against
that binary, presents native dialogs, and dispatches role agents. It
never re-derives a decision the engine already made.
The Claude Code adapter lives at adapters/claude/ and passes the same
shared parity suite (internal/adaptertest) this adapter's plugin tests
do.
Artifact map
.codex-plugin/plugin.json— the plugin manifest (name, description, version, author). Theskills/andhooks/hooks.jsoncomponent directories are auto-discovered by Codex CLI; there is nothing else to declare here yet. Codex plugins cannot bundle agent TOMLs or prompts (see Install order below).hooks/hooks.json— two hooks:PreToolUseonapply_patchrunsorch guard codex, which reads the tool-call event on stdin and denies the write when Orch's policy (Assist read-only, Delivery worktree containment) says so. All file mutations on Codex CLI — create, update, delete, rename — route through this single tool, so this one matcher covers every file mutation the same way Claude Code's four-tool matcher does. An allow is silence: guard never bypasses Codex CLI's own approval and sandbox prompts.SessionStartonstartup|resumerunsorch hook codex session-start, which injects a short context block at session start when the current directory is inside an Orch repository with a readable configuration and state: the operating mode, the memhub mode, a reminder to load theorch-architectskill before planning or making a change, and a pointer to theorch-setupskill for the three setup interviews. Outside an Orch repository, or if the repository is unreadable, it injects nothing and never blocks the session. (Codex has noclear/compactSessionStart sources to mirror Claude Code's matcher, hencestartup|resumeonly.)
skills/orch-architect/SKILL.md— the Architect's standing posture: never edit tracked files directly, never re-derive engine policy, theorch run status --json/ PROJECT.md / memhub-recall session ritual, mode conduct, the five-agent dispatch whitelist and theconcurrency.max_subagentscap, and memhub write discipline.skills/orch-delivery/SKILL.md— the Delivery wire contract: the scratch-file JSON request/response pattern for everyorch run <verb>call,PlanDocconstruction, the plan gate and its four-optionrequest_user_inputquestion, activation, the full per-issue dispatch → execute → pr-open → review → ci → merge-report → merge gate → merge → cleanup loop, completion and the memhub wrap-up cue, escalation, and block/abandon.skills/orch-setup/SKILL.md— the shared step-loop driver for the threeorch <cmd> --stepinterviews: the resubmitted-in-fullAnswerSet, one-question-at-a-time presentation ofquestionsdocuments via Codex'srequest_user_inputprimitive, thesummary/blockers/complete/aborteddocument kinds, and each interview's terminal form.agents/orch-scout.toml,agents/orch-implementer.toml,agents/orch-specialist.toml,agents/orch-reviewer.toml,agents/orch-reviewer-safe.toml— the five role agents the Architect dispatches during Delivery, each pinning its ownmodelandmodel_reasoning_effort.orch-reviewer-safeis the §10 safe-review downgrade encoding: since Codex has no per-spawn model override, the downgrade the engine computes for a mechanical/low-risk/ fully-specified/unsurprising issue has to be an installed TOML of its own, dispatched by name exactly likeorch-reviewer.
No commands/ directory and no prompt files ship with this adapter:
Codex custom prompts (slash commands) are deprecated, so skills are
invoked directly instead of through a command surface (a recorded
decision, not an oversight).
Install order
-
Install the
orchbinary onPATHfirst. Every hook in this plugin shells out to it with a bare command; if it is not resolvable, both hooks fail (see Known limitations). -
Install this plugin (
.codex-plugin/plugin.json, its bundledhooks/andskills/) from the repository's marketplace manifest:codex plugin marketplace add kninetimmy/orch codex plugin add orch@orchThe manifest at the repository root (
.claude-plugin/marketplace.json) serves both hosts — install this host's entry by its exact name,orch. The Claude entry (orch-claude, sourceadapters/claude) also shows up incodex plugin listas installable (verified on codex-cli 0.144.1); it bundles Claude-format components and is not this adapter. -
Approve the plugin-bundled hooks' one-time trust prompt. Codex CLI requires the user to review and trust plugin-bundled hooks before they run at all. Until that approval happens,
orch guard codexandorch hook codex session-startsilently do not run — the same fail-open class as a missing binary, not a denial or an error. -
Copy the five agent TOMLs under
agents/into the project's.codex/agents/(or~/.codex/agents/for a user-global install). Codex plugins cannot bundle agent definitions, so this copy is a separate manual step every install of this adapter needs, not something the plugin installs for you — the marketplace install in step 2 does not remove it.orch render-agents(PRD §22) is the mechanical alternative to a manual copy: it renders the same five files, withmodel/model_reasoning_effortsubstituted from the repository's ownhosts.codex.roles, into the project's.codex/agents/directly. -
Enable the
request_user_inputquestion primitive — verified on codex-cli 0.144.1, both of these in~/.codex/config.toml:[tools.experimental_request_user_input] [features] default_mode_request_user_input = true(The
[tools]entry is a struct, not a boolean — the bare table enables it with defaults.) The setup interviews and the plan/merge gates present their questions throughrequest_user_input, which is otherwise gated to plan mode; without these the skills degrade to plain-text questions the human answers by typing. -
Run
orch doctorto confirm the environment (Git, GitHub, memhub, configuration) is healthy.
Known limitations
These are accepted for this PR and the adapter as a whole, not open bugs:
- Bash-mediated writes are not guarded. The
PreToolUsehook only coversapply_patch. A file write made throughBash(for exampleecho > fileor a script) does not go throughorch guard codex. Codex CLI's own approval and sandbox prompts onBashare the backstop here. This limitation is shared with the Claude adapter — but on Codex,Bashitself is a hookable tool_name, which makes the shared task-27 core feature (closing this gap for real) more tractable on this host than on Claude Code, where no comparable hook point exists for shell-mediated writes today. - A missing
orchbinary fails open, not closed. As described under Install order: a hook command that cannot be found exits non-blocking by the hook protocol's own rules, so both the write guard and the session-start context silently stop working rather than erroring loudly. The same is true while the one-time hook trust approval is outstanding. Install order,orch doctor, and the visible absence of session-start context are the mitigations; there is no way to make either gap fail closed from inside the hook itself. - No per-spawn model override. Unlike Claude Code (which can at
least prompt-cue an effort it cannot enforce), Codex CLI dispatches an
agent with whatever
model/model_reasoning_effortits installed TOML pins — there is no host mechanism to override either per dispatch.orch-delivery's spawn step therefore requires the routed(model, effort)to match an installedorch-*TOML exactly, and stops and tells the human rather than silently substituting a mismatched agent or reporting the routed selection as if it ran.orch-reviewer-safeexists specifically so the §10 safe-downgrade row has a real installed TOML to dispatch, instead of dead-ending at that same stop-and-tell-human rule on every routine downgrade. - A configured non-default model is applied by
orch render-agents, not automatically. A repository that overrides the §10 defaults must runorch render-agents(PRD §22) itself — install and upgrade do not run it for you — to re-render the five files under.codex/agents/from the currenthosts.codex.rolesbefore the override takes effect for dispatched agents. - An unrecognized future
apply_patchenvelope directive denies, fail-closed.internal/guard's envelope parser treats any***directive line it does not already recognize as a malformed envelope and denies the write (seeErrPatchEnvelope). This is deliberate — an upstream Codex CLI format addition must never silently allow an unparsed write — but it also means a Codex CLI upgrade that adds a newapply_patchdirective kind can cause spurious denies untilorchitself is updated to parse it.
Host version
Formal minimum: the first hooks-GA Codex CLI release (2026-05-14).
Rationale: apply_patch PreToolUse hook events only fire correctly on
builds after openai/codex PR #18391 (2026-04-22, the fix that made
apply_patch write events actually reach hooks); a build older than
that silently never sees file-write events at all — no error, no
denial, just a guard hook that never runs. That failure mode has no
visible symptom short of a write landing that should have been denied,
which is why the floor is pinned at the first release confirmed to
include the fix rather than left to a de-facto smoke-tested version, as
the Claude adapter's is.
Two behaviors verified live in the task-30 parity smoke (codex-cli
0.144.1, 2026-07-12): PreToolUse hooks do fire on dispatched-agent
(subagent) apply_patch calls — load-bearing here, since Codex agent
definitions carry no tool whitelist, so scout/reviewer read-only
discipline is mechanically enforced by the guard, not just by
developer_instructions — and request_user_input is root-thread
only, so a dispatched agent can never raise a native question.
As defense in depth — complementary to the guard hook, not a
substitute for it, and no configuration is shipped by this adapter to
enforce it — a repository operator adopting this adapter should also
consider running Codex CLI with sandbox_mode set to workspace-write
and a non-never approval_policy. The guard hook denies by orch's own
Delivery/Assist policy; Codex CLI's own sandbox and approval settings
are a second, independent layer that catches what the hook cannot (a
missing binary, an unapproved plugin, a write the hook fails to
classify). One Windows caveat, observed live: workspace-write
requires Codex's sandbox helper infrastructure to be installed and
healthy — where it is absent, every agent apply_patch fails before
any mutation (orchestrator_helper_launch_failed), which stops
Delivery execution cold. Verify the sandbox works before adopting that
mode on Windows.
Documentation
¶
Overview ¶
Package codex anchors the adapters/codex directory as a Go package so its validation tests (plugin_test.go) build and run under the module's ordinary `go test ./...`. The Codex CLI plugin itself is non-Go: the manifest, hooks, skills, and agent TOMLs under this directory are read directly by Codex CLI, never compiled. This file carries no runtime code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AgentTOMLs embed.FS
AgentTOMLs embeds the five shipped Codex agent definitions under agents/ verbatim (LF-only, byte-identical to what this plugin ships, since go:embed reads the file at build time). internal/agents reads from this embed.FS to render `.codex/agents/*.toml` from the effective configuration, so the shipped adapter files and `orch render-agents`'s output share exactly one canonical source and cannot silently diverge: any edit to a file under agents/ changes what both the plugin ships and the render command produces, in the same build.
Functions ¶
This section is empty.
Types ¶
This section is empty.