feat(hooks): wire Codex notify from the manifest (codex.notify event)#40
Merged
Conversation
A hook with event = "codex.notify" is installed into ~/.claude/hooks like any other, but registered in ~/.codex/config.toml as the notify program (absolute path — Codex execs directly). One managed file now serves both Claude (settings.json hooks) and Codex (notify), removing the source/copy drift. The config.toml edit is surgical (preserves other keys + comments, backs up); a replaced prior notify is reported so it can be chained via env.
- handle multi-line notify arrays in the surgical regex (was single-line only) - escape control characters (U+0000-001F) in TOML strings - refuse >1 codex.notify hooks (Codex has one notify slot) instead of silent clobber - use errors.Is(err, os.ErrNotExist) and wrap CodexConfigPath error - tests for multi-line array preservation + control-char escaping
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.
Makes `vd install hooks` configure both agents from one manifest, fixing the source/copy drift where Claude ran the vd-installed copy while Codex ran the source script.
What
/.claude/hooks/` like any other, but registered in `/.codex/config.toml` as the `notify` program.Result
One managed file (`~/.claude/hooks/agent-notify.py`) serves both Claude (Stop/Notification) and Codex (notify) — no drift, and `vd install hooks` covers Codex on fresh machines.
Tests
New `codex_test.go` (preserve/replace/already-ours/missing-file/append/escaping/unwire/foreign/backup) + manifest + command tests. Live smoke: model + comment preserved, notify rewritten to abs path, settings.json untouched, chain-warning shown. `go test -race`, vet, lint all green.