121 lines
4.8 KiB
Bash
Executable File
121 lines
4.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Behavior check: the dotfiles crew dispatch sends ordinary workers to
|
|
# DeepSeek v4.1 Flash on OpenCode, documentation tasks to Beam Free, and keeps
|
|
# the design exception. It reads the config through firstmate's own bootstrap
|
|
# validator and verbose facts, which is the supported surface that reports the
|
|
# 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 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)
|
|
CONFIG="$ROOT/home/.config/firstmate/crew-dispatch.json"
|
|
FM_ROOT=${FM_ROOT:-"$HOME/Documents/firstmate"}
|
|
BOOTSTRAP="$FM_ROOT/bin/fm-bootstrap.sh"
|
|
|
|
[ -f "$CONFIG" ] || { echo "FAIL: missing $CONFIG" >&2; exit 1; }
|
|
if [ ! -x "$BOOTSTRAP" ]; then
|
|
echo "SKIP: firstmate bootstrap not found at $BOOTSTRAP"
|
|
exit 0
|
|
fi
|
|
|
|
TMP=$(mktemp -d "${TMPDIR:-/tmp}/crew-dispatch.XXXXXX")
|
|
cleanup() { rm -rf "$TMP"; }
|
|
trap cleanup EXIT
|
|
|
|
mkdir -p "$TMP/home/config"
|
|
cp "$CONFIG" "$TMP/home/config/crew-dispatch.json"
|
|
printf 'manual\n' > "$TMP/home/config/backlog-backend"
|
|
|
|
out=$(FM_HOME="$TMP/home" FM_ROOT_OVERRIDE="$TMP/home" FM_BOOTSTRAP_VERBOSE_FACTS=1 \
|
|
"$BOOTSTRAP" 2>"$TMP/stderr")
|
|
|
|
fail() {
|
|
echo "FAIL: $1"
|
|
printf '%s\n' "$out" | sed 's/^/ /'
|
|
sed 's/^/ /' "$TMP/stderr"
|
|
exit 1
|
|
}
|
|
|
|
if printf '%s\n' "$out" | grep -q '^CREW_DISPATCH: invalid'; then
|
|
fail "firstmate rejected the crew dispatch config"
|
|
fi
|
|
|
|
default=$(printf '%s\n' "$out" | grep '^BOOTSTRAP_INFO: crew dispatch default: ' || true)
|
|
[ -n "$default" ] || fail "firstmate reported no default dispatch profile"
|
|
|
|
case "$default" in
|
|
*opencode/opencode-go/deepseek-v4.1-flash*) ;;
|
|
*) fail "default workers are not OpenCode + DeepSeek v4.1 Flash" ;;
|
|
esac
|
|
case "$default" in
|
|
*pi/*|*codex/*) fail "default workers still resolve to a Pi/Codex profile" ;;
|
|
esac
|
|
|
|
docs=$(printf '%s\n' "$out" | grep '^BOOTSTRAP_INFO: crew dispatch rule: Documentation tasks' || true)
|
|
[ -n "$docs" ] || fail "no documentation dispatch rule"
|
|
case "$docs" in
|
|
*'-> opencode/opencode-go/beam-free') ;;
|
|
*) fail "documentation tasks do not resolve to opencode/opencode-go/beam-free" ;;
|
|
esac
|
|
|
|
design=$(printf '%s\n' "$out" | grep '^BOOTSTRAP_INFO: crew dispatch rule: Design, architecture' || true)
|
|
[ -n "$design" ] || fail "the preserved design rule is missing"
|
|
case "$design" in
|
|
*'-> pi/openai-codex/gpt-6.1-sol/xhigh') ;;
|
|
*) fail "the design exception no longer resolves to Pi + GPT-6.1 Sol" ;;
|
|
esac
|
|
|
|
ui=$(printf '%s\n' "$out" | grep '^BOOTSTRAP_INFO: crew dispatch rule: UI work' || true)
|
|
[ -n "$ui" ] || fail "the UI image-context rule is missing"
|
|
case "$ui" in
|
|
*opencode-go/deepseek-v4.1-flash*) ;;
|
|
*) 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"
|