feat: codex-models discovery via codex debug models (visibility==list)
This commit is contained in:
1 parent
cebe3e72af
commit
f062d03a4e
2 files changed
+49
No files matched your search
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# List Codex models with reasoning levels (visibility==list only).
|
||||
# Usage: ./scripts/codex-models.sh OR codex debug models | ./scripts/codex-models.sh --stdin
|
||||
# Requires: codex CLI, jq
|
||||
set -eu
|
||||
if [[ "${1:-}" == "--stdin" ]]; then
|
||||
jq '[.models[] | select(.visibility=="list") | {slug, display_name, default: .default_reasoning_level, levels: [.supported_reasoning_levels[].effort], description}]'
|
||||
else
|
||||
codex debug models | jq '[.models[] | select(.visibility=="list") | {slug, display_name, default: .default_reasoning_level, levels: [.supported_reasoning_levels[].effort], description}]'
|
||||
fi
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||
RUN=$HERE/../scripts/codex-models.sh
|
||||
TMP=$(mktemp -d)
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
# stub codex that returns fake catalog
|
||||
mkdir -p "$TMP/bin"
|
||||
cat > "$TMP/bin/codex" <<'STUB'
|
||||
#!/usr/bin/env bash
|
||||
if [[ "$1" == "debug" && "$2" == "models" ]]; then
|
||||
cat <<'JSON'
|
||||
{"models":[
|
||||
{"slug":"gpt-5.6-sol","display_name":"GPT-5.6-Sol","visibility":"list","default_reasoning_level":"low","supported_reasoning_levels":[{"effort":"low"},{"effort":"high"}],"description":"x"},
|
||||
{"slug":"gpt-reserve","visibility":"hide","default_reasoning_level":"medium","supported_reasoning_levels":[{"effort":"low"}],"description":"y"},
|
||||
{"slug":"gpt-5.5","display_name":"GPT-5.5","visibility":"list","default_reasoning_level":"medium","supported_reasoning_levels":[{"effort":"low"},{"effort":"medium"}],"description":"z"}
|
||||
]}
|
||||
JSON
|
||||
else echo "stub: unknown args $*" >&2; exit 1; fi
|
||||
STUB
|
||||
chmod +x "$TMP/bin/codex"
|
||||
|
||||
# 1. filters hide, keeps list (via stub, PATH hoist)
|
||||
OUT=$(PATH="$TMP/bin:$PATH" "$RUN")
|
||||
echo "$OUT" | grep -q "gpt-5.6-sol"
|
||||
echo "$OUT" | grep -q "gpt-5.5"
|
||||
if echo "$OUT" | grep -q "gpt-reserve"; then echo "FAIL: hide leaked"; exit 1; fi
|
||||
echo "$OUT" | grep -q '"levels": \['
|
||||
echo "models test: PASS (stubbed)"
|
||||
|
||||
# 2. --stdin path piped fixture
|
||||
cat > "$TMP/fake.json" <<'JSON'
|
||||
{"models":[{"slug":"a","visibility":"list","display_name":"A","default_reasoning_level":"low","supported_reasoning_levels":[{"effort":"low"}],"description":"d"}]}
|
||||
JSON
|
||||
OUT2=$(cat "$TMP/fake.json" | "$RUN" --stdin)
|
||||
echo "$OUT2" | grep -q '"slug": "a"'
|
||||
echo "stdin test: PASS"
|
||||
echo "ALL PASS"
|
||||
Reference in new issue
Block a user