diff --git a/.claude/skills/grok/scripts/ask-grok.sh b/.claude/skills/grok/scripts/ask-grok.sh index e0d534f..70144aa 100644 --- a/.claude/skills/grok/scripts/ask-grok.sh +++ b/.claude/skills/grok/scripts/ask-grok.sh @@ -72,9 +72,15 @@ REPO_ROOT="${CLAUDETOOLS_ROOT:-$(cd "$SCRIPT_DIR/../../../.." 2>/dev/null && pwd # run grok headless. $1=timeout secs; rest=extra flags. Reads $PF -> $OUT. # Never fails the script on grok's exit code (Cancelled is expected; we read artifacts). +# Use gtimeout on macOS (from brew coreutils), timeout on Linux/Windows. +TIMEOUT_CMD="timeout" +if [[ "$OSTYPE" == "darwin"* ]]; then + TIMEOUT_CMD="$(command -v gtimeout 2>/dev/null || echo timeout)" +fi + run_grok() { local to="$1"; shift - timeout "$to" "$GROK" --prompt-file "$PF" --output-format json \ + "$TIMEOUT_CMD" "$to" "$GROK" --prompt-file "$PF" --output-format json \ --permission-mode dontAsk --no-subagents --no-plan --cwd "$RUN_CWD" "$@" \ >"$OUT" 2>"$TMP/err.txt" || true }