#!/bin/bash
# Portable copy of the executable wrapper used in the before/after captures.
# Set these two paths for each revision; STATE_DIR must start empty.
set -e
: "${REAL_OPENCODE:?Path to the real @opencode/cli 2.2.7 executable}"
: "${STATE_DIR:?Fresh isolated directory for this revision}"
export XDG_CONFIG_HOME="$STATE_DIR/config"
export XDG_DATA_HOME="$STATE_DIR/data"
export XDG_CACHE_HOME="$STATE_DIR/cache"
export XDG_STATE_HOME="$STATE_DIR/state"
if [[ " $* " == *" serve "* ]]; then
  exec systemd-run --user --scope --quiet -p CPUQuota=10% "$REAL_OPENCODE" "$@"
fi
exec "$REAL_OPENCODE" "$@"
