Skip to content

Commit d910366

Browse files
peterdrierclaude
andcommitted
fix: remove unnecessary companion allowlist and add jq availability check
The regex `codex\s` already won't match `codex-companion` (hyphen, not space), so the substring allowlist was redundant and could be bypassed with chained commands. Removed it. Also added a jq availability check that passes through gracefully if jq is missing — no hard dependency introduced but the guard works when jq is present (which we expect). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ff00b11 commit d910366

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

plugins/codex/hooks/block-direct-codex-cli.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/bin/bash
22
# PreToolUse hook: block direct "codex" CLI invocations and redirect to the plugin.
3+
4+
# jq is expected but not a hard dependency — pass through if unavailable.
5+
command -v jq &>/dev/null || exit 0
6+
37
INPUT=$(cat)
48
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
59

610
# Match bare "codex" at the start of the command or after a pipe/semicolon/&&
11+
# "codex-companion" won't match because \s requires whitespace after "codex".
712
if echo "$COMMAND" | grep -qE '(^|[;&|]\s*)codex\s'; then
8-
# Allow calls that go through the plugin's own companion script
9-
if echo "$COMMAND" | grep -q 'codex-companion\.mjs'; then
10-
exit 0
11-
fi
1213
echo "Do not call the codex CLI directly. Use the codex plugin instead: /codex:rescue for tasks, /codex:review for reviews, /codex:status for status, /codex:result for results." >&2
1314
exit 2
1415
fi

0 commit comments

Comments
 (0)