Initial patterm project

This commit is contained in:
2026-05-14 13:37:20 +01:00
commit 69ef09aac4
40 changed files with 6521 additions and 0 deletions

82
cmd/spike/testdata/run-matrix.sh vendored Executable file
View File

@@ -0,0 +1,82 @@
#!/usr/bin/env bash
# Spike test matrix. Runs ./bin/spike against each target in sequence so a
# human can confirm by eye that the grid dump matches what the program would
# render in their own terminal.
#
# Run this from the project root:
# make spike
# ./cmd/spike/testdata/run-matrix.sh
#
# Each target's raw PTY recording lands in spike-<pid>.bytes and the final
# grid dump is appended to spike-report-<timestamp>.txt.
set -u
ROOT=$(cd "$(dirname "$0")/../../.." && pwd)
BIN=${SPIKE_BIN:-$ROOT/bin/spike}
REPORT=$ROOT/spike-report-$(date +%Y%m%dT%H%M%S).txt
if [[ ! -x "$BIN" ]]; then
echo "spike binary not found at $BIN — run 'make spike' first" >&2
exit 1
fi
note() { printf '\n=== %s ===\n' "$*" | tee -a "$REPORT"; }
have() { command -v "$1" >/dev/null 2>&1; }
run_case() {
local label=$1; shift
note "$label"
printf 'argv: %q ' "$@" | tee -a "$REPORT"
printf '\n'
printf 'Press Ctrl-] in the spike to dump the grid.\n'
printf 'Grid dumps go to spike-<pid>.grid.log (tail -f in another terminal to watch live).\n'
printf 'The child must exit cleanly to advance.\n'
printf 'Press Enter when ready to start this case (or s to skip)... '
read -r ans
if [[ "$ans" == "s" ]]; then
echo 'skipped' | tee -a "$REPORT"
return
fi
# Tee spike's stderr so grid dumps are visible AND captured in the report.
# Without this, Ctrl-] dumps end up in $REPORT silently and look like
# the hotkey did nothing.
"$BIN" -- "$@" 2> >(tee -a "$REPORT" >&2)
echo "---" >> "$REPORT"
}
note "spike test matrix — $(date -Is)"
"$BIN" -h 2>>"$REPORT" || true
# 1. Trivial stream-mode sanity check.
run_case "echo + sleep (stream sanity)" sh -c 'echo hello; sleep 1'
# 2. Interactive shell.
run_case "bash -i (prompt + history)" bash -i
# 3. Alt-screen line editor.
if have vim; then
run_case "vim README.md (alt-screen)" vim "$ROOT/SPEC.md"
else
echo "skip vim: not installed" | tee -a "$REPORT"
fi
# 4. Alt-screen continuous redraw.
if have htop; then
run_case "htop (alt-screen, redraw)" htop
else
echo "skip htop: not installed" | tee -a "$REPORT"
fi
# 57. Real targets — the actual point of the spike.
for agent in claude opencode codex; do
if have "$agent"; then
run_case "$agent (real target)" "$agent"
else
echo "skip $agent: not installed" | tee -a "$REPORT"
fi
done
note "matrix complete. report: $REPORT"
echo
echo "Next step: write up the per-target verdict in SPIKE-REPORT.md."