Files
hx/tests/schema_e2e.sh
johannesandClaude Sonnet 5.5 dfec176f43
build / version (push) Successful in 16s
build / build (aarch64-apple-darwin) (push) Successful in 10m46s
build / build (x86_64-unknown-linux-musl) (push) Successful in 10m45s
build / release (push) Successful in 31s
feat: add --schema, --max-turns and rpc --ask
- hx -p --schema <file> validates the final answer against a JSON schema,
  with one retry that includes the validation errors
- max_turns config key and --max-turns cap the main agent's model calls
- hx --mode rpc --ask sends permission requests to the client instead of
  auto-allowing bash/write/edit calls

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-28 14:15:03 +01:00

19 lines
985 B
Bash

#!/bin/sh
set -eu
root=$(cd "$(dirname "$0")/.." && pwd)
tmp=$(mktemp -d)
trap 'kill $srv 2>/dev/null; rm -rf "$tmp"' EXIT
port=$((20000 + ($$ + 7) % 20000))
echo '[[["text","no json here"]],[["text","```json\n{\"name\":\"Ann\"}\n```"]]]' > "$tmp/turns.json"
python3 "$root/tests/fake_anthropic.py" $port "$tmp/turns.json" & srv=$!
mkdir -p "$tmp/home/.hx" "$tmp/repo"
echo '{"claude":{"access":"fake-token","refresh":"r","expires":99999999999999}}' > "$tmp/home/.hx/auth.json"
echo '{"type":"object","required":["name"],"properties":{"name":{"type":"string"}}}' > "$tmp/schema.json"
sleep 0.5
cd "$tmp/repo"
export HOME="$tmp/home" HX_BASE_URL="http://127.0.0.1:$port"
out=$("$root/target/debug/hx" -p "who" --schema "$tmp/schema.json" 2> "$tmp/err")
[ "$out" = '{"name":"Ann"}' ] || { echo "FAIL: schema output: $out"; cat "$tmp/err"; exit 1; }
curl -s "http://127.0.0.1:$port/" | grep -q 'does not match the schema' || { echo "FAIL: no retry prompt"; exit 1; }
echo "schema e2e ok"