codex

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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). The skills/ and hooks/hooks.json component 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:
    • PreToolUse on apply_patch runs orch 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.
    • SessionStart on startup|resume runs orch 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 the orch-architect skill before planning or making a change, and a pointer to the orch-setup skill 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 no clear/compact SessionStart sources to mirror Claude Code's matcher, hence startup|resume only.)
  • skills/orch-architect/SKILL.md — the Architect's standing posture: never edit tracked files directly, never re-derive engine policy, the orch run status --json / PROJECT.md / memhub-recall session ritual, mode conduct, the five-agent dispatch whitelist and the concurrency.max_subagents cap, and memhub write discipline.
  • skills/orch-delivery/SKILL.md — the Delivery wire contract: the scratch-file JSON request/response pattern for every orch run <verb> call, PlanDoc construction, the plan gate and its four-option request_user_input question, 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 three orch <cmd> --step interviews: the resubmitted-in-full AnswerSet, one-question-at-a-time presentation of questions documents via Codex's request_user_input primitive, the summary/blockers/complete/aborted document 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 own model and model_reasoning_effort. orch-reviewer-safe is 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 have its own project TOML under .codex/agents/, dispatched by name exactly like orch-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

  1. Install the orch binary on PATH first. Every hook in this plugin shells out to it with a bare command; if it is not resolvable, both hooks fail (see Known limitations).

  2. Install this plugin (.codex-plugin/plugin.json, its bundled hooks/ and skills/) from the repository's marketplace manifest:

    codex plugin marketplace add kninetimmy/orch
    codex plugin add orch@orch
    

    The 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, source adapters/claude) also shows up in codex plugin list as installable (verified on codex-cli 0.144.1); it bundles Claude-format components and is not this adapter.

  3. 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 codex and orch hook codex session-start silently do not run — the same fail-open class as a missing binary, not a denial or an error.

  4. After orch init is merged in a repository, run orch render-agents there. Codex plugins cannot bundle agent definitions, so the command writes the five canonical TOMLs to the project's .codex/agents/, substituting model and model_reasoning_effort from the effective hosts.codex.roles. It also renders every other enabled host, and refuses before writing unless every enabled destination is git-ignored. Run it again after changing role configuration or upgrading Orch. Before this change a manual five-file copy was an accepted alternative; after it, orch render-agents is the single per-repository workflow.

  5. Enable the request_user_input question 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 through request_user_input, which is otherwise gated to plan mode; without these the skills degrade to plain-text questions the human answers by typing.

  6. Run orch doctor to confirm the environment (Git, GitHub, memhub, configuration) is healthy.

Upgrade

The marketplace-add and plugin-add commands above are for a first installation. Upgrade an existing adapter with:

codex plugin marketplace upgrade orch

Restart Codex CLI after the upgrade so it loads the updated adapter.

Known limitations

These are accepted for this PR and the adapter as a whole, not open bugs:

  • Bash-mediated writes are not guarded. The PreToolUse hook only covers apply_patch. A file write made through Bash (for example echo > file or a script) does not go through orch guard codex. Codex CLI's own approval and sandbox prompts on Bash are the backstop here. This limitation is shared with the Claude adapter — but on Codex, Bash itself 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.
  • Role read-only-ness rests on developer_instructions, not on the guard. orch guard's --role narrowing is the only mechanism that could make a role mechanically read-only, and this adapter never passes it: Codex hooks are plugin-global rather than scoped per dispatched agent, so hooks/hooks.json runs the bare orch guard codex command. What the guard enforces is containment — inside a registered worktree, on its registered branch, in a writable phase — applied to every agent alike; it cannot attribute a write to a role. Since Codex agent definitions carry no tool whitelist, nothing mechanical stops orch-scout or either reviewer from writing inside a worktree the guard currently treats as writable, including the one under review. Their read-only discipline is stated in their developer_instructions and rests there. The Claude adapter leaves --role unused for the same reason. Its tool whitelist backs orch-scout's read-only-ness fully — orch-scout carries no Bash — but orch-reviewer and orch-reviewer-safe both carry Bash, so their whitelist leaves that same Bash-mediated write path open there too, even though it excludes every guarded write tool; their read-only discipline for anything Bash-mediated rests on instructions, same as this host's.
  • A missing orch binary 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. Codex CLI dispatches an agent with whatever model/model_reasoning_effort its project TOML pins — there is no host mechanism to override either per dispatch. This is not a Codex-specific constraint relative to Claude Code: both hosts require the routed selection to match an active project agent definition exactly, because Claude Code's Task tool model parameter only accepts coarse tier aliases (sonnet/opus/haiku/fable), never an exact version string, so a per-spawn override cannot express a routed selection there either. orch-delivery's spawn step therefore stops and tells the human on a mismatch, on either host, rather than silently substituting a mismatched agent or reporting the routed selection as if it ran. The genuine Codex-specific piece is effort: it is pinned in the project TOML and enforced by the host, whereas Claude Code subagent spawns take no effort parameter at all and the routed effort is only conveyed as a prompt cue. orch-reviewer-safe exists specifically so the §10 safe-downgrade row has a real project 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 run orch render-agents (PRD §22) itself — install and upgrade do not run it for you — to re-render every enabled host's project definitions from the effective role configuration before the override takes effect for dispatched agents. orch doctor and plan activation fail closed on missing, unreadable, or stale definitions.
  • An unrecognized future apply_patch envelope 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 (see ErrPatchEnvelope). 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 new apply_patch directive kind can cause spurious denies until orch itself 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 it puts every dispatched agent's writes under the guard's worktree, branch, and phase containment, the only mechanical write boundary this adapter ships — 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

View Source
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.

View Source
var PluginManifestJSON string

PluginManifestJSON is the shipped plugin manifest and therefore the canonical adapter version for this build.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL