fix(skills): use command -v instead of which for codex detection#1197
Open
mvanhorn wants to merge 2 commits intogarrytan:mainfrom
Open
fix(skills): use command -v instead of which for codex detection#1197mvanhorn wants to merge 2 commits intogarrytan:mainfrom
mvanhorn wants to merge 2 commits intogarrytan:mainfrom
Conversation
which is not POSIX; its behavior varies across platforms (Debian debianutils, macOS csh script, bash function alias, Busybox missing entirely). In non-interactive shells spawned by tool runners, PATH and hash state can diverge so which codex returns "command not found" for a binary that is on PATH and runnable. The Codex gate then silently skips with CODEX_NOT_AVAILABLE. Replace which codex with command -v codex across: - codex/SKILL.md.tmpl (single source of truth for the codex binary check) - scripts/resolvers/review.ts (3 callsites) - scripts/resolvers/design.ts (3 callsites) command -v is POSIX-specified and uses the shell's own resolution, so if command -v X returns a path, X is runnable. Update two test assertions that checked for the literal string "which codex" in test/skill-validation.test.ts and test/skill-e2e-plan.test.ts. autoplan/ already uses the command -v codex pattern; this aligns the rest of the codebase with the existing convention. Fixes garrytan#1193
bun run gen:skill-docs --host all output following the which -> command -v swap in codex/SKILL.md.tmpl and scripts/resolvers/*.ts. Refreshed test/fixtures/golden/claude-ship-SKILL.md and factory-ship-SKILL.md from the regenerated ship SKILL.md for each host. codex-ship-SKILL.md was already byte-identical to the regenerated .agents/ output and did not need a refresh.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace
which codexwithcommand -v codexin the Codex availability gate used by/review,/ship,/office-hours,/plan-ceo-review,/plan-eng-review,/plan-design-review,/plan-devex-review,/design-consultation,/design-review, and/codexitself.Why this matters
whichis not POSIX. Its behavior varies across platforms:/usr/bin/whichfrom debianutils, which scans PATHwhichto a bash function that reads the hash tablewhichat allIn non-interactive shells spawned by tool runners, PATH hydration and hash state can diverge in ways that cause
which codexto miss a binary thatcommand -v codexandtype codexresolve correctly. The reporter on #1193 hit this on Ubuntu/Pop!_OS with@openai/codex@0.125.0installed under nvm:When the availability probe misses,
/reviewsilently falls back to "Claude adversarial only" without telling the user. The reporter approved a PR that way.command -vis POSIX-specified and uses the same resolution the shell itself uses to run a command, so a positive result means the binary is runnable.Changes
Source files edited directly:
codex/SKILL.md.tmplline 45 (one callsite in the template used by/codex)scripts/resolvers/review.tslines 269, 428, 557 (three callsites consumed by/reviewand/ship)scripts/resolvers/design.tslines 13, 515, 691 (three callsites consumed by design/review skills)test/skill-validation.test.tsline 1320 (assertion updated to match new literal)test/skill-e2e-plan.test.tsline 779 (assertion updated to match new literal)Regenerated via
bun run gen:skill-docs --host all:codex/SKILL.md,review/SKILL.md,ship/SKILL.md,office-hours/SKILL.md,plan-ceo-review/SKILL.md,plan-eng-review/SKILL.md,plan-design-review/SKILL.md,plan-devex-review/SKILL.md,design-consultation/SKILL.md,design-review/SKILL.mdtest/fixtures/golden/claude-ship-SKILL.mdandtest/fixtures/golden/factory-ship-SKILL.mdrefreshed from regenerated ship output (the codex-ship golden was already byte-identical to the regenerated.agents/output)gstack already uses
command -v codexinautoplan/SKILL.md.tmpl:250andtest/helpers/providers/gpt.ts:20. This aligns the rest of the codebase with that existing convention.Not in scope
pair-agent/SKILL.md.tmpl:131andpair-agent/SKILL.md:1177use the samewhich ngrok 2>/dev/nullshape. The reporter's issue is about codex detection, so ngrok is left alone. Happy to open a follow-up PR for it.test/fixtures/golden-ship-claude.md(top-level, not undergolden/) still containswhich codexbut is not referenced by any test and was last touched in 2026-04 via a community PR. Treated as an orphan artifact.Testing
Three unrelated tests fail on both
upstream/mainand this branch (no compiled binaries > 2MB,read_secret_to_env > rejects invalid var names,Opus 4.7 overlay > Fan out). Verified by running them onupstream/mainHEAD before branching.Fixes #1193