v1.0.124 shipped Codex matchers containing `(?!.*context-mode)` and
`(?!plugin_context-mode_)`. Codex's Rust `regex` crate does NOT support
look-around, so it rejects the matcher at boot with "look-around not
supported" — every Codex user on v1.0.124 is broken. Pin Codex matchers
to charset `[A-Za-z0-9_|]` so `is_exact_matcher`
(refs/platforms/codex/codex-rs/hooks/src/events/common.rs:152)
short-circuits the regex engine entirely. Hook BODY's `isExternalMcpTool()`
filter (hooks/core/routing.mjs:379) preserves end-to-end semantics.
RED→GREEN: tests/adapters/codex.test.ts "Codex matcher #547 — is_exact_matcher charset compliance"
Extends PR #532's external-MCP routing protection from Claude Code to Codex CLI.
Adds `mcp__(?!.*context-mode)` to the PreToolUse matcher so slack / telegram /
gdrive / notion-style MCPs trigger the context-guidance nudge before their
large payloads flood the model's context window.
Verified Codex MCP wire shape (`mcp__<server>__<tool>`) via configs/codex/hooks.json
existing matchers and tests/adapters/codex.test.ts:56-141. Codex own context-mode
tools surface as both bare (ctx_*) and `mcp__<server>__ctx_*` — both already
wired by the explicit entries above the new catch-all, and the negative
lookahead excludes any `mcp__` server segment containing `context-mode` to
prevent double-firing.
- src/adapters/codex/hooks.ts: export EXTERNAL_MCP_MATCHER_PATTERN
- src/adapters/codex/index.ts: append the pattern to PRE_TOOL_USE_MATCHER_PATTERN
- configs/codex/hooks.json: mirror runtime matcher
- README.md: update documented Codex matcher (drift-guarded by codex.test.ts)
- tests/adapters/codex-external-mcp-routing.test.ts: 4-test vertical slice
* ci: update install stats
* ci: update install stats
* ci: update install stats
* ci: update install stats
* ci: update install stats
* ci: update install stats
* ci: update install stats
* docs(codex): document hooks feature flag rename
* fix(codex): manage native hooks.json lifecycle
* fix(codex): capture apply_patch continuity events
* fix(codex): harden hooks.json lifecycle and apply_patch continuity
Create ~/.codex before writing hooks.json, distinguish missing, invalid JSON, and unreadable hook configs, and refuse to overwrite malformed user hook files.
Only resolve prior Read errors after successful follow-up edits, and make ctx-upgrade fail clearly when hook configuration cannot be updated instead of reporting a false success.
Also document [features].hooks as the preferred key while keeping [features].codex_hooks as a legacy alias in current Codex builds.
* fix(codex): normalize hook errors and guard patch continuity
Normalize Codex PostToolUse error state into the extractor input, block failed apply_patch calls from emitting error_resolved, file continuity, or plan continuity events, and harden hooks.json lifecycle handling against schema-invalid but parseable shapes.
Also keep context-mode upgrade running Codex hook repair on the already-latest path so doctor-driven hook fixes are not skipped.
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Mert Köseoğlu <bm.ksglu@gmail.com>
Codex CLI does not support additionalContext in PreToolUse responses,
causing "PreToolUse hook returned unsupported additionalContext" error.
- Remove PreToolUse from configs/codex/hooks.json
- Remove PreToolUse from CodexAdapter.generateHookConfig()
- formatPreToolUseResponse: silently drop "context" decisions (return {})
- Update README + platform-support.md: hooks.json example without PreToolUse
- Routing handled via AGENTS.md instead
Closes#225
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>