#!/usr/bin/env bash # Pass iff the scripts work and the agent kept a finished task list. set -euo pipefail cd "$(dirname "$0")" fail() { echo "check: $*"; exit 1; } [[ -x greet.sh && -x count.sh ]] || fail "scripts missing or not executable" [[ "$(./greet.sh)" == "Hello, world!" ]] || fail "greet.sh without argument" [[ "$(./greet.sh Ada)" == "Hello, Ada!" ]] || fail "greet.sh Ada" [[ "$(./count.sh notes.txt | tr -d ' ')" == "3" ]] || fail "count.sh notes.txt" set +e ./count.sh >/dev/null 2>&1 rc=$? set -e [[ "$rc" -eq 2 ]] || fail "count.sh without argument should exit 2 (got $rc)" [[ -s SCRIPTS.md ]] || fail "SCRIPTS.md missing" grep -q greet.sh SCRIPTS.md && grep -q count.sh SCRIPTS.md || fail "SCRIPTS.md does not mention both scripts" # The session must show todo_write ending with every item done. python3 - <<'PY' || fail "no finished todo_write list in the session" import glob, json, re, sys last = None for path in glob.glob(".agent/*.jsonl") + glob.glob(".agent/sessions/*.jsonl"): for line in open(path, encoding="utf-8"): try: m = json.loads(line) except ValueError: continue c = m.get("content") or "" r = re.search(r"todo list updated: (\d+)/(\d+) done", c) if r: last = (int(r.group(1)), int(r.group(2))) sys.exit(0 if last and last[1] >= 3 and last[0] == last[1] else 1) PY echo "check: PASSED"