Skip to content

Fix Codex PostToolUse hooks that emit empty stdout for pathless edits #156

Description

@JordanCoin

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-dir> as a workaround.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions