#!/usr/bin/env bash set -euo pipefail # CodexHelper.sh — minimal wrapper to invoke Codex CLI # - Finds a codex binary (env `CODEX_BIN`, or `codex`, or `codex-cli`) # - Uses the repository's prompts/system_prompt.md by default # - Passes through any extra args to the codex binary SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="${SCRIPT_DIR}/.." SYSTEM_PROMPT_PATH="${REPO_ROOT}/prompts/system_prompt.md" if [[ ! -f "${SYSTEM_PROMPT_PATH}" ]]; then echo "Error: system prompt not found at ${SYSTEM_PROMPT_PATH}" >&2 exit 1 fi # Binary detection: prefer $CODEX_BIN, then common names if [[ -n "${CODEX_BIN:-}" ]]; then BIN="${CODEX_BIN}" elif command -v codex >/dev/null 2>&1; then BIN="$(command -v codex)" elif command -v codex-cli >/dev/null 2>&1; then BIN="$(command -v codex-cli)" else echo "Error: Could not find codex binary. Set CODEX_BIN or install 'codex'/'codex-cli'." >&2 exit 1 fi # Try a common flag name for supplying a system prompt. Adjust if needed. # Additional args are forwarded so callers can customize behavior. exec "${BIN}" --system-prompt "${SYSTEM_PROMPT_PATH}" "$@"