Support Claude and Codex hook adapters#22
Merged
Merged
Conversation
Record the decisions from the design review: keep apply_patch as an adapter detail normalized into Write/Edit/Delete, keep Delete and PermissionRequest parsed but unmatchable for now, limit Codex setup to local hooks.json, and keep nudge check scoped to repository file validation. Remove the open questions section now that the RFC has concrete implementation direction.
Add a provider-neutral hook model and evaluator, then route Claude Code through it before adding Codex hook parsing, response rendering, setup, and docs. Codex apply_patch is normalized into Write, Edit, and Delete events so existing file-content rules work without exposing apply_patch as a rule target. Keep PermissionRequest and Delete parsed but unmatchable, preserve fail-open behavior for unparseable patches, narrow Claude setup to handled events, and add Codex-local .codex/hooks.json setup with inline TOML-hook warnings. Update README, AGENTS, CLAUDE, and the rule docs to describe the shared agent-hook surface. Testing: cargo fmt --all; cargo test -p nudge; cargo run -p nudge -- claude docs; cargo run -p nudge -- codex docs; git diff --check; ASCII/smart-punctuation scan for edited docs.
Run the repository-level CI mode against the Codex hook adapter implementation and address the dogfood rule findings it surfaced. Replace newly added qualified paths with local imports and use pretty_assert_eq! in the new tests so nudge check is green on the current tree. Testing: cargo run -p nudge -- check; cargo test -p nudge; git diff --check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this change
PreToolUse,UserPromptSubmit,Write,Edit,WebFetch, andBash.apply_patchpayloads.apply_patchis normalized intoWrite,Edit, and parsed-but-unmatchableDeleteevents.PermissionRequestis parsed for both providers but intentionally passes through until Nudge has a permission-specific rule surface..codex/hooks.jsoncommand hooks forPreToolUseandUserPromptSubmit.Configuration changes after merge
Existing Claude Code users can keep their current rules. To refresh local hook setup and remove older Nudge-managed
PostToolUse/Stophooks, run:Codex users can install equivalent project-local hooks with:
After
nudge codex setup, restart open Codex sessions, run/hooks, review the new Nudge command hooks, and trust them.If Codex hooks do not appear, verify that the project
.codex/layer is trusted and[features].hookshas not been disabled in Codex config.Testing steps performed
cargo test -p nudgeI also installed Codex hooks locally in this repo:
Then I smoke-tested the real Codex hook path by attempting to write a Rust file with an inline
usestatement throughapply_patch. The hook blocked the write before the file was created:Notes
WebSearch/WebFetchinterception is documented as unsupported for current Codex hooks, so the docs andnudge validatewarn aboutWebFetchrules in Codex-targeted projects instead of claiming enforcement there.nudge checkremains repository-file validation. It evaluates file rules directly from the shared rule schema and does not attempt to replay Codex hook payloads.