Skip to content

Codex SessionStart hook fails because hooks.json uses host placeholders in shell command #64

@cofin

Description

@cofin

Summary

The Flow Codex plugin SessionStart hook fails on startup under Codex CLI v0.135.0 because the installed hooks/hooks.json command uses ${extensionPath}${/} placeholders inside a shell command. Codex appears to execute the command through the shell without expanding those placeholders, so Bash treats ${/} as an invalid parameter expansion.

Environment

  • Codex CLI: 0.135.0
  • Plugin: flow@flow-marketplace version 0.20.5
  • Installed manifest: ~/.codex/plugins/cache/flow-marketplace/flow/0.20.5/hooks/hooks.json

Current command

"command": "bun ${extensionPath}${/}hooks${/}session-start.js || node ${extensionPath}${/}hooks${/}session-start.js || bash ${extensionPath}${/}hooks${/}session-start.sh"

Reproduction

Starting Codex in a repo with Flow enabled shows:

SessionStart hook (failed)
error: hook exited with code 1

Running the configured command directly reproduces it:

bash -lc 'bun ${extensionPath}${/}hooks${/}session-start.js || node ${extensionPath}${/}hooks${/}session-start.js || bash ${extensionPath}${/}hooks${/}session-start.sh'
# bash: line 1: ${extensionPath}${/}hooks${/}session-start.js: bad substitution
# exit=1

Calling the script by absolute path succeeds:

node ~/.codex/plugins/cache/flow-marketplace/flow/0.20.5/hooks/session-start.js
# emits hookSpecificOutput.additionalContext JSON and exits 0

Local workaround applied

I patched the installed cache manifest locally to use this command:

"command": "node /home/cody/.codex/plugins/cache/flow-marketplace/flow/0.20.5/hooks/session-start.js || bash /home/cody/.codex/plugins/cache/flow-marketplace/flow/0.20.5/hooks/session-start.sh"

After that, a fresh normal codex exec --json --ephemeral "Respond exactly: OK" completed successfully, and the log rows for that thread had 0 WARN/ERROR/hook failure entries.

Expected fix

Ship a Codex-safe hook manifest for Flow, or update the command template to use whatever plugin-root substitution/environment Codex officially supports. The current ${extensionPath}${/} form is not safe when Codex runs the hook command through Bash.

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