diff --git a/skills/claude-codex-delegation/install.sh b/skills/claude-codex-delegation/install.sh index cf9976f0d8e..c0837a13e93 100755 --- a/skills/claude-codex-delegation/install.sh +++ b/skills/claude-codex-delegation/install.sh @@ -114,11 +114,21 @@ if ! command -v timeout &> /dev/null; then if [[ "$(uname)" == "Darwin" ]]; then echo " Install with: brew install coreutils" fi - ((MISSING++)) + MISSING=$((MISSING + 1)) else info "timeout: available" fi +if ! command -v script &> /dev/null; then + error "'script' (from util-linux) is required for Codex PTY support." + if [[ "$(uname)" == "Darwin" ]]; then + echo " Install with: brew install util-linux" + fi + MISSING=$((MISSING + 1)) +else + info "script: available" +fi + if command -v tmux &> /dev/null; then info "tmux: available" else @@ -126,7 +136,7 @@ else fi if [[ $MISSING -gt 0 ]]; then - error "Missing $MISSING required system dependency. Install it and rerun." + error "Missing $MISSING required system dependencies. Install them and rerun." exit 1 fi @@ -198,35 +208,35 @@ if command -v claude &> /dev/null || $DRY_RUN; then info "claude CLI: OK" else error "claude CLI: not found" - ((ERRORS++)) + ERRORS=$((ERRORS + 1)) fi if command -v codex &> /dev/null || $DRY_RUN; then info "codex CLI: OK" else error "codex CLI: not found" - ((ERRORS++)) + ERRORS=$((ERRORS + 1)) fi if [[ -f "$SKILL_DIR/SKILL.md" ]] || $DRY_RUN; then info "SKILL.md: OK" else error "SKILL.md: not found at $SKILL_DIR" - ((ERRORS++)) + ERRORS=$((ERRORS + 1)) fi if [[ -x "$SKILL_DIR/scripts/delegate.sh" ]] || $DRY_RUN; then info "scripts/delegate.sh: OK" else error "scripts/delegate.sh: not found or not executable" - ((ERRORS++)) + ERRORS=$((ERRORS + 1)) fi if [[ -x "$SKILL_DIR/scripts/tmux-session.sh" ]] || $DRY_RUN; then info "scripts/tmux-session.sh: OK" else error "scripts/tmux-session.sh: not found or not executable" - ((ERRORS++)) + ERRORS=$((ERRORS + 1)) fi # --- Auth check --- diff --git a/skills/claude-codex-delegation/scripts/delegate.sh b/skills/claude-codex-delegation/scripts/delegate.sh index 4fddf524ee6..38c49cf2304 100755 --- a/skills/claude-codex-delegation/scripts/delegate.sh +++ b/skills/claude-codex-delegation/scripts/delegate.sh @@ -118,8 +118,7 @@ fi # Codex requires a git repository — fail fast instead of silently mutating if [[ "$AGENT" == "codex" ]]; then - cd "$WORKDIR" - if [[ ! -d .git ]] && ! git rev-parse --git-dir > /dev/null 2>&1; then + if ! (cd "$WORKDIR" && { [[ -d .git ]] || git rev-parse --git-dir > /dev/null 2>&1; }); then echo "Error: Codex requires a git repository but $WORKDIR is not one." >&2 echo "Initialize one with: cd $WORKDIR && git init" >&2 exit 1 @@ -167,9 +166,10 @@ run_delegation() { ;; codex) # Codex requires a PTY — use script(1) to provide one. + # -e: propagate child exit code (without it, script always returns 0) # Run through bash -c so printf '%q' quoting is interpreted correctly # (script passes commands to /bin/sh which may be dash, not bash). - script -q -c "bash -c $(printf '%q' "$(build_codex_cmd) $(printf '%q' "$PROMPT")")" "$LOG_FILE" || exit_code=$? + script -e -q -c "bash -c $(printf '%q' "$(build_codex_cmd) $(printf '%q' "$PROMPT")")" "$LOG_FILE" || exit_code=$? ;; esac diff --git a/skills/claude-codex-delegation/scripts/tmux-session.sh b/skills/claude-codex-delegation/scripts/tmux-session.sh index a8701b0b647..2fe80dee542 100755 --- a/skills/claude-codex-delegation/scripts/tmux-session.sh +++ b/skills/claude-codex-delegation/scripts/tmux-session.sh @@ -128,8 +128,7 @@ case "$ACTION" in # Codex requires a git repo if [[ "$AGENT" == "codex" ]]; then - cd "$WORKDIR" - if [[ ! -d .git ]] && ! git rev-parse --git-dir > /dev/null 2>&1; then + if ! (cd "$WORKDIR" && { [[ -d .git ]] || git rev-parse --git-dir > /dev/null 2>&1; }); then echo "Error: Codex requires a git repository but $WORKDIR is not one." >&2 echo "Initialize one with: cd $WORKDIR && git init" >&2 exit 1