diff --git a/readme.md b/readme.md index 2de8145..45a8e5f 100644 --- a/readme.md +++ b/readme.md @@ -51,7 +51,7 @@ The captain confirmed the split on 2026-11-15. Leave it unchanged: ```bash ./tests/fm-launcher.sh --live # installed zshrc; fails while it still launches Pi ./tests/fm-launcher.sh # generated zshrc; must pass -./tests/crew-dispatch.sh # firstmate bootstrap view of the routing +./tests/crew-dispatch.sh # routing via firstmate, model IDs via opencode models ./tests/run.sh # all checks ``` diff --git a/tests/crew-dispatch.sh b/tests/crew-dispatch.sh index 1836f57..8b28e3f 100755 --- a/tests/crew-dispatch.sh +++ b/tests/crew-dispatch.sh @@ -6,8 +6,10 @@ # effective dispatch profile. # # Firstmate matches the natural-language `when` text with its own judgment, so -# this check pins the declared routing and the schema, not a model call. -# It skips when firstmate is not installed. +# this check pins the declared routing and the schema, not a model call. It then +# confirms every OpenCode-harness model ID against OpenCode's own catalog, so a +# mistyped ID fails here instead of when a crew spawns. +# It skips the parts that need firstmate or OpenCode when they are not installed. set -euo pipefail ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P) @@ -75,6 +77,44 @@ case "$ui" in *) fail "the UI rule no longer resolves to DeepSeek v4.1 Flash" ;; esac +# The model IDs above come from the same file the routing check reads, so a +# typo would still pass them. OpenCode's own catalog is the independent oracle: +# a model it does not list fails only when a crew spawns. Confirm each +# OpenCode-harness model against that catalog. +OPENCODE_JSON=${OPENCODE_CONFIG:-$HOME/.config/opencode2/opencode.json} +if ! command -v opencode >/dev/null 2>&1 || ! command -v python3 >/dev/null 2>&1; then + echo "SKIP: opencode or python3 not on PATH, cannot confirm the model IDs" +elif [ ! -e "$OPENCODE_JSON" ]; then + echo "SKIP: no isolated OpenCode config at $OPENCODE_JSON, cannot confirm the model IDs" +else + catalog=$(OPENCODE_CONFIG="$OPENCODE_JSON" timeout 120 opencode models 2>/dev/null || true) + if [ -z "$catalog" ]; then + echo "SKIP: opencode models printed nothing, cannot confirm the model IDs" + else + models=$(python3 - "$CONFIG" <<'PY' +import json, sys + +config = json.load(open(sys.argv[1])) +uses = list(config.get("default") or []) +for rule in config.get("rules") or []: + use = rule.get("use") + uses.extend(use if isinstance(use, list) else [use]) +for use in uses: + if isinstance(use, dict) and use.get("harness") == "opencode" and use.get("model"): + print(use["model"]) +PY + ) + # Deduplicate so a model named by two profiles is confirmed once. + models=$(printf '%s\n' "$models" | awk 'NF && !seen[$0]++') + while IFS= read -r model; do + [ -n "$model" ] || continue + printf '%s\n' "$catalog" | grep -qxF "$model" \ + || fail "$model is not in the OpenCode catalog (opencode models)" + echo "PASS: $model exists in the OpenCode catalog" + done <<< "$models" + fi +fi + echo "PASS: default workers -> opencode/opencode-go/deepseek-v4.1-flash" echo "PASS: documentation -> opencode/opencode-go/beam-free" echo "PASS: design exception preserved -> pi/openai-codex/gpt-6.1-sol/xhigh"