codex

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 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. Question and approval checks are document-contract checks, not proof of live agent behavior.

Before #292, the manual plugin was Orch's Codex execution path. After #292, it remains that path; an internal metadata preflight adds no execution CLI or model turns. See the native protocol subset for its authentication/catalog checks, bounds and version-sensitive Windows diagnostics. The manual adapter's workflows and restrictions below still hold.

#293 adds a separate native workspace preflight and an opt-in no-model Windows isolation smoke in the same protocol document. Its worker/reviewer command profiles were tested with synthetic fixtures; at that stage native model execution was unavailable because 0.159.2 could not establish the required inherited-tool boundary. Since #322, the existing native bridge conditionally admits reviewed Windows amd64 Codex 0.160.0 with verified controls; other versions remain refused. The preflights added no execution CLI and did not change any manual role's guard or instruction-based read-only restrictions. Live evaluation trials and current-version qualification remain outstanding; see the protocol document for the exact boundary.

Released engine v0.15.2 pairs with manual adapter 0.13.0. Guided setup and manual Delivery are implemented, and completed child usage has been captured in a fresh manual Delivery exercise. Automatic Codex Architect usage, Codex grants and context relay remain missing. Installation and source/CI success do not prove a fresh installed initial-setup/survey exercise or full host parity. See the current parity matrix, including the separate Claude/OpenCode baseline caveats. The protected-list status reports added by #434 are unreleased source behavior, not part of the installed v0.15.2 binary.

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 logical outcomes presented according to current host capabilities, 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 supported native questions or plain text, 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). Use the root agent-led installation prompt; its installer verifies the release binary against published checksums before execution.

  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. Restart Codex after installation before relying on the plugin. Inside an initialized repository, check for the Orch session-start block; installation during an existing session does not prove the hooks and skills were loaded there.

  4. Check the current session's question-tool capabilities. Before this update, this step prescribed both tables below in ~/.codex/config.toml (verified on codex-cli 0.144.1) and treated them as enabling native setup and approval questions, including a four-option native plan gate:

    [tools.experimental_request_user_input]
    
    [features]
    default_mode_request_user_input = true
    

    On that version, the [tools] entry was a struct, not a boolean; the bare table enabled its defaults. After this update, use request_user_input only when available, permitted for the question's purpose, and able to represent all options within its current contract; otherwise present the same complete question as plain text. All four logical plan outcomes and each PR's fresh merge choice remain. Historical flags do not override current tool restrictions, including prohibitions on approval requests and limits on option counts. Those restrictions describe request_user_input, not every question tool; any other tool must satisfy its own current contract and the same requirements for complete questions and human approval.

    Setup, plan activation, and each PR merge require an actual affirmative human answer. Defaults, preselection, silence, timeout, unavailable tools, or an unanswered question never count as approval.

  5. Open the repository root and ask your agent: Initialize Orch in this repository using the orch-setup skill. It guides the host/model choices, protected-path survey and final change summary, then opens the initialization PR only after your approval. Review and merge that PR yourself. Preserve existing host configuration and project instructions outside Orch's managed block. See the full per-repository setup prompt.

    Earlier root guidance made bare orch init sound interactive. Bare orch init, orch configure and orch configure-local print reports; the setup skill drives the interactive steps. For an existing project, ask the agent to configure Orch using that skill. Codex does not ship Claude's /orch:init or /orch:configure commands.

  6. Bootstrap leaves the primary checkout unchanged. After the initialization PR is merged, update that checkout with the merged configuration, for example with git pull --ff-only on the repository's default branch. Confirm .orchestrator/config.toml is present locally, then run orch render-agents. 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. Re-render after effective role changes, or after an upgrade changes definitions or doctor reports them stale. Earlier guidance said to re-render after every upgrade; unchanged definitions need no refresh. Before the rendering workflow a manual five-file copy was an accepted alternative; afterward, orch render-agents is the single per-repository workflow.

  7. Run orch doctor --host codex in the initialized repository. Check every failure and advisory; other configured hosts' failures are reported as advisories rather than hidden. This checks the manual adapter environment, not native-evaluation qualification or full parity.

Upgrade

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

codex plugin marketplace upgrade orch

Update the compatible engine/adapter pair together between runs in Assist; never replace either during an active run. Restart Codex CLI after the upgrade so it loads the updated adapter, run orch render-agents if definitions changed or are stale, and run orch doctor --host codex. Preserve existing configuration. Compare actual installed skills and source provenance with the intended release, then exercise the installed workflow under a fresh approved plan; matching version labels alone are insufficient. See the root upgrade and compatibility guidance.

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. Effort is pinned the same way on both hosts: in the project TOML on Codex and in the agent definition's effort frontmatter field on Claude Code, and the host applies it. 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 was root-thread only. Before this update, that observation was generalized to say a dispatched agent could never raise a native question. After this update, it remains an observation about request_user_input on that tested version, not every question tool or version. Check the current tool contract; dispatched agents surface questions and approval needs through the Architect.

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