8 Commits

Author SHA1 Message Date
Mert Koseoglu 675fec69c9 fix(codex): drop look-around from PreToolUse matcher (closes #547 partial — 1 of 1)
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"
2026-05-13 16:28:42 +03:00
Mert Koseoglu 996f8c4420 feat(codex): route external MCP tools through PreToolUse (closes #529 partial — codex)
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
2026-05-12 13:19:45 +03:00
Marcus 043a1f52be [codex] add compact hook support (#492)
* feat(codex): add compact hook support

* chore(codex): address hook review cleanup

---------

Co-authored-by: boederzeng <86715671+boederzeng@users.noreply.github.com>
2026-05-09 21:48:19 +03:00
李明皓 990586a2d6 fix(codex): normalize hook errors and guard patch continuity (#479)
* 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>
2026-05-09 12:09:53 +03:00
Marcus 91cd6dfeb2 feat(codex): wire prompt and stop hooks (#360)
Co-authored-by: boederzeng <86715671+boederzeng@users.noreply.github.com>
Co-authored-by: Mert Köseoğlu <bm.ksglu@gmail.com>
2026-04-27 18:49:09 +03:00
Mert Koseoglu 838bfd6749 Revert "fix(codex): remove PreToolUse from Codex hooks — additionalContext unsupported"
This reverts commit 5ade0be640.
2026-04-03 23:06:52 +03:00
Mert Koseoglu 5ade0be640 fix(codex): remove PreToolUse from Codex hooks — additionalContext unsupported
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>
2026-04-03 23:05:21 +03:00
Mert Koseoglu 725951a24a 1.0.59
fix: add PreToolUse to Codex hooks.json + stop to Cursor hooks.json

README:
- Codex: hooks no longer optional, PreToolUse added for routing enforcement
- Codex: removed from "no hook support" references (lines 747, 830)
- Codex: continuity table updated (PostToolUse/SessionStart: Yes)
- Cursor: stop hook in hooks.json example

Configs:
- configs/codex/hooks.json: created with PreToolUse+PostToolUse+SessionStart
- configs/cursor/hooks.json: added stop hook entry

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 21:15:27 +03:00