Skip to content

feat(codex): add native hooks integration#899

Open
sf-jin-ku wants to merge 1 commit intortk-ai:developfrom
sf-jin-ku:codex-integration-by-hooks
Open

feat(codex): add native hooks integration#899
sf-jin-ku wants to merge 1 commit intortk-ai:developfrom
sf-jin-ku:codex-integration-by-hooks

Conversation

@sf-jin-ku
Copy link
Copy Markdown

Summary

  • add native Codex PreToolUse integration via rtk hook codex
  • extend rtk init --codex to patch .codex/config.toml and .codex/hooks.json
  • fall back to prompt-only Codex setup on Windows and honor CODEX_HOME for global installs

Problem

rtk init --codex was prompt-only. It wrote RTK.md and patched AGENTS.md, but it did not install Codex lifecycle hooks, so Codex had no hard guardrail to route supported raw Bash commands through rtk.

What changed

Hook runtime

  • add rtk hook codex
  • reuse the existing rewrite source of truth via get_rewritten()
  • for supported raw Bash commands, return Codex-native permissionDecision: "deny" with the exact rtk ... replacement
  • pass through unchanged for unsupported commands, excluded commands, heredocs, and already-rtk commands

Codex install / uninstall / show

  • rtk init --codex now patches:
    • RTK.md
    • AGENTS.md
    • .codex/config.toml
    • .codex/hooks.json
  • ensure features.codex_hooks = true
  • install one PreToolUse matcher group for Bash
  • rtk init --show --codex now reports local/global Codex hook state
  • rtk init --codex --uninstall now supports local uninstall
  • leave codex_hooks = true in place on uninstall, but remove RTK-managed hook entries

Compatibility / edge cases

  • use CODEX_HOME for global Codex path resolution instead of hardcoding ~/.codex
  • on Windows, fall back to the old prompt-only Codex setup because upstream Codex disables lifecycle hooks there
  • local .codex installs still depend on Codex project trust
  • update Codex-facing docs and hook README/test layout to match the current hook structure under src/hooks and hooks/codex

Test plan

  • cargo test --all
  • cargo build && RTK=target/debug/rtk bash hooks/codex/test-rtk-rewrite.sh

Notes

Codex currently does not support transparent updatedInput rewrites for PreToolUse, so this integration uses deny-and-retry instead of the Claude/Cursor transparent rewrite flow.

@sf-jin-ku sf-jin-ku marked this pull request as ready for review March 28, 2026 14:47
@sf-jin-ku sf-jin-ku changed the title [codex] add native hooks integration for Codex CLI feat(codex): add native hooks integration with Windows fallback Mar 28, 2026
@sf-jin-ku sf-jin-ku changed the title feat(codex): add native hooks integration with Windows fallback feat(codex): add native hooks integration Mar 28, 2026
Signed-off-by: Jin Ku <jin.ku@sendbird.com>
@sf-jin-ku sf-jin-ku force-pushed the codex-integration-by-hooks branch from 06e614b to 93537d3 Compare March 28, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant