feat(agent-codex): mature Codex plugin to match Claude Code support
Brings the Codex agent plugin to feature parity with Claude Code by
fixing four key gaps and hardening the shell wrapper infrastructure.
## Changes
**`packages/plugins/agent-codex/src/index.ts`**
- Permission flag: `--approval-mode full-auto` → `--dangerously-bypass-approvals-and-sandbox`
- Terminal-based activity detection with Codex-specific patterns:
idle (bare prompts), waiting_input (approval prompts), active (spinners, esc to interrupt)
- PATH-based shell wrappers (`~/.ao/bin/gh`, `git`, `ao-metadata-helper.sh`):
- `gh` wrapper captures `pr/create` and `pr/merge` output to update PR metadata;
all other commands use `exec` for transparent passthrough (no stderr merging)
- `git` wrapper captures `checkout -b` / `switch -c` to update branch metadata
- Metadata helper escapes sed metacharacters (`&`, `|`, `\`) in values
- Uses `grep -Fxv` (fixed-string) instead of regex for PATH cleaning
- Validates `AO_DATA_DIR`/`AO_SESSION` paths to prevent arbitrary file overwrites
(rejects traversal, resolves symlinks, allowlists `~/.ao/` and `/tmp/`)
- `getEnvironment()` prepends `~/.ao/bin` to PATH for wrapper interception
- `setupWorkspaceHooks()` / `postLaunchSetup()` install wrappers atomically
(temp file + rename) and append AGENTS.md section
- `getActivityState()` returns `{ state: "exited" }` when dead, `null` when running
**`packages/core/src/lifecycle-manager.ts`**
- Branch-based PR fallback: when `metadata.pr` is missing, calls
`scm.detectPR()` via `gh pr list --head <branch>` to auto-discover PRs
for agents without hook systems (Codex, Aider, OpenCode)
## Test coverage
- 85 tests in `agent-codex` (up from 27), replicating Claude Code test patterns:
detectActivity edge cases, isProcessRunning boundaries, setupWorkspaceHooks
file I/O behavior, shell wrapper content verification, atomic write validation
- 245 tests in core pass
- All 22 packages typecheck clean
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>