fix(firstmate): route documentation to Beam Free and guard the OpenCode 2 launcher
Add a documentation dispatch rule that uses opencode-go/beam-free while the default workers stay on opencode-go/deepseek-v4.1-flash. Preserve the existing UI rule and the Pi/GPT design exception. Add live checks for the two operator-facing contracts: - tests/fm-launcher.sh sources the zshrc that home-manager generates, runs fm with harmless pi and oc2 spies, and requires OpenCode 2 through oc2. - tests/crew-dispatch.sh reads the dispatch config through firstmate's own bootstrap validator and asserts the default, documentation, UI, and design profiles. Document the permanent fm decision, the no-mistakes model split, and the minimal install procedure after merge.
This commit is contained in:
1 parent
5566b982c2
commit
0aa25b27f0
7 files changed
+295
-4
No files matched your search
Executable
+80
@@ -0,0 +1,80 @@
|
||||
#!/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 skips when firstmate is 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
|
||||
|
||||
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"
|
||||
Executable
+129
@@ -0,0 +1,129 @@
|
||||
#!/usr/bin/env bash
|
||||
# Behavior check: a fresh interactive zsh runs `fm` and the permanent launcher
|
||||
# starts OpenCode 2 through ~/.local/bin/oc2, never Pi.
|
||||
#
|
||||
# The check reads the zshrc that the real home-manager configuration generates
|
||||
# (the same file a rebuild installs), sources it in an interactive zsh, and runs
|
||||
# `fm` with two harmless spies:
|
||||
# - a `pi` spy first on PATH, which catches a Pi launch;
|
||||
# - a spy named by OPENCODE2_BIN, which the real ~/.local/bin/oc2 wrapper
|
||||
# execs instead of the OpenCode binary.
|
||||
# Nothing here launches a real firstmate primary, Pi, or OpenCode, so no
|
||||
# session lock is taken.
|
||||
#
|
||||
# Usage:
|
||||
# tests/fm-launcher.sh # check the configuration source (default)
|
||||
# tests/fm-launcher.sh --live # check the installed ~/.zshrc
|
||||
# tests/fm-launcher.sh --zshrc F # check a specific generated zshrc
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
|
||||
MODE=source
|
||||
ZSHRC=''
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--live) MODE=live; shift ;;
|
||||
--zshrc)
|
||||
[ $# -ge 2 ] || { echo "fm-launcher: --zshrc needs a path" >&2; exit 2; }
|
||||
MODE="file"; ZSHRC=$2; shift 2 ;;
|
||||
-h|--help)
|
||||
awk 'NR == 1 { next } /^#/ { sub(/^# ?/, ""); print; next } { exit }' "$0"
|
||||
exit 0 ;;
|
||||
*) echo "fm-launcher: unknown argument $1" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
TMP=$(mktemp -d "${TMPDIR:-/tmp}/fm-launcher.XXXXXX")
|
||||
cleanup() { rm -rf "$TMP"; }
|
||||
trap cleanup EXIT
|
||||
|
||||
mkdir -p "$TMP/bin"
|
||||
cat > "$TMP/bin/pi" <<'SH'
|
||||
#!/usr/bin/env bash
|
||||
printf 'pi' >> "$FM_TEST_SPY_LOG"
|
||||
for arg in "$@"; do printf '|%s' "$arg" >> "$FM_TEST_SPY_LOG"; done
|
||||
printf '\n' >> "$FM_TEST_SPY_LOG"
|
||||
exit 0
|
||||
SH
|
||||
cat > "$TMP/bin/opencode2-spy" <<'SH'
|
||||
#!/usr/bin/env bash
|
||||
printf 'oc2' >> "$FM_TEST_SPY_LOG"
|
||||
for arg in "$@"; do printf '|%s' "$arg" >> "$FM_TEST_SPY_LOG"; done
|
||||
printf '\n' >> "$FM_TEST_SPY_LOG"
|
||||
exit 0
|
||||
SH
|
||||
chmod +x "$TMP/bin/pi" "$TMP/bin/opencode2-spy"
|
||||
printf '{}\n' > "$TMP/opencode.json"
|
||||
|
||||
case "$MODE" in
|
||||
live)
|
||||
ZSHRC="$HOME/.zshrc"
|
||||
LABEL="installed ~/.zshrc"
|
||||
;;
|
||||
file)
|
||||
LABEL="$ZSHRC"
|
||||
;;
|
||||
source)
|
||||
command -v nix >/dev/null 2>&1 \
|
||||
|| { echo "fm-launcher: nix is required to build the configured zshrc" >&2; exit 2; }
|
||||
ZSHRC="$TMP/zshrc"
|
||||
nix eval --raw --impure --expr \
|
||||
"(builtins.getFlake (toString $ROOT)).darwinConfigurations.\"lt-mbp\".config.home-manager.users.laptran.home.file.\"./.zshrc\".text" \
|
||||
> "$ZSHRC"
|
||||
LABEL="home-manager zshrc generated from $ROOT"
|
||||
;;
|
||||
esac
|
||||
|
||||
[ -r "$ZSHRC" ] || { echo "fm-launcher: cannot read $ZSHRC" >&2; exit 2; }
|
||||
|
||||
: > "$TMP/spy.log"
|
||||
: > "$TMP/stderr"
|
||||
|
||||
set +e
|
||||
# shellcheck disable=SC2016 # the snippet expands inside the interactive zsh
|
||||
FM_TEST_ZSHRC="$ZSHRC" \
|
||||
FM_TEST_SPY_LOG="$TMP/spy.log" \
|
||||
OPENCODE2_BIN="$TMP/bin/opencode2-spy" \
|
||||
OPENCODE_CONFIG="$TMP/opencode.json" \
|
||||
PATH="$TMP/bin:$PATH" \
|
||||
timeout 60 zsh -f -i -c '
|
||||
source "$FM_TEST_ZSHRC" || exit 4
|
||||
if ! alias fm >/dev/null 2>&1; then
|
||||
echo "fm-launcher: no fm alias in the sourced zshrc" >&2
|
||||
exit 3
|
||||
fi
|
||||
eval fm
|
||||
' >/dev/null 2>"$TMP/stderr"
|
||||
status=$?
|
||||
set -e
|
||||
|
||||
launched=''
|
||||
[ -s "$TMP/spy.log" ] && launched=$(head -n 1 "$TMP/spy.log")
|
||||
|
||||
if [ "$status" -eq 3 ]; then
|
||||
echo "FAIL: $LABEL does not define an fm alias"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$status" -ne 0 ]; then
|
||||
echo "FAIL: fm launch from $LABEL exited $status"
|
||||
sed 's/^/ /' "$TMP/stderr"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$launched" ]; then
|
||||
echo "FAIL: fm from $LABEL launched nothing the spies could see"
|
||||
sed 's/^/ /' "$TMP/stderr"
|
||||
exit 1
|
||||
fi
|
||||
if [ "${launched%%|*}" != oc2 ]; then
|
||||
echo "FAIL: fm from $LABEL launched ${launched%%|*} instead of OpenCode 2 (oc2)"
|
||||
echo " recorded launch: $launched"
|
||||
exit 1
|
||||
fi
|
||||
if grep -q '^pi' "$TMP/spy.log"; then
|
||||
echo "FAIL: fm from $LABEL also launched Pi"
|
||||
sed 's/^/ /' "$TMP/spy.log"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "PASS: fm from $LABEL launched OpenCode 2 via oc2 ($launched)"
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run the dotfiles configuration checks that need the live machine.
|
||||
#
|
||||
# The launcher check builds the zshrc from the home-manager configuration and
|
||||
# runs `fm` with spies. The dispatch check reads the crew dispatch config through
|
||||
# firstmate's bootstrap validator. Neither starts a real agent session.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
|
||||
status=0
|
||||
|
||||
"$ROOT/tests/fm-launcher.sh" || status=1
|
||||
"$ROOT/tests/crew-dispatch.sh" || status=1
|
||||
|
||||
exit "$status"
|
||||
Reference in new issue
Block a user