Problem
Codex invokes the registered PostToolUse hook after apply_patch, Edit, and Write. Codemap currently returns success with empty stdout when the hook payload has no recognized file_path (notably pathless apply_patch payloads). Codex requires a valid JSON hook response and reports hook returned invalid post-tool-use JSON output.
Reproduction
From the repository root:
printf "%s\n" "{\"tool_name\":\"apply_patch\",\"tool_input\":{},\"tool_response\":{}}" | codemap hook post-edit --agent=codex --integration=codex-setup
Expected current observation: exit 0 with empty stdout.
TDD acceptance criteria
- Add a failing regression test for a Codex
PostToolUse invocation whose payload yields no file paths.
- Codex-mode
post-edit always emits exactly one valid JSON hook envelope on stdout, including a safe no-op result.
- A file-path payload still records provenance and returns its existing contextual output inside the JSON envelope.
- Hook stdout contains no non-JSON prefixes, ANSI output, or extra JSON records.
- Preserve Claude-mode hook behavior.
- Focused hook tests and
go test ./... pass.
Likely scope
cmd/hooks.go and adjacent hook tests only. Do not edit user-wide ~/.codex/hooks.json as a workaround.
Problem
Codex invokes the registered PostToolUse hook after
apply_patch,Edit, andWrite. Codemap currently returns success with empty stdout when the hook payload has no recognizedfile_path(notably pathlessapply_patchpayloads). Codex requires a valid JSON hook response and reportshook returned invalid post-tool-use JSON output.Reproduction
From the repository root:
Expected current observation: exit 0 with empty stdout.
TDD acceptance criteria
PostToolUseinvocation whose payload yields no file paths.post-editalways emits exactly one valid JSON hook envelope on stdout, including a safe no-op result.go test ./...pass.Likely scope
cmd/hooks.goand adjacent hook tests only. Do not edit user-wide~/.codex/hooks.jsonas a workaround.