Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

1.5 KB
Raw Blame
#!/usr/bin/env bash
# Fetch Trail of Bits' skills into upstream/ at the commit VERSIONS pins — read-only, from its public
# repository, sparse and blob-less so only the plugins this harness loads come down. Idempotent: a
# matching upstream/.harness-commit means it is already there. Run by setup.sh; cwd = the package dir.
set -euo pipefail
. ./VERSIONS
if [ -f upstream/.harness-commit ] && [ "$(cat upstream/.harness-commit)" = "${UPSTREAM_COMMIT}" ]; then
  echo "ok   ${UPSTREAM_NAME} @ ${UPSTREAM_COMMIT:0:12} already fetched"
  exit 0
fi
command -v git >/dev/null 2>&1 || { echo "miss git on PATH"; exit 1; }
echo "     fetching ${UPSTREAM_REPO} @ ${UPSTREAM_COMMIT:0:12} (${UPSTREAM_SPARSE_MODE} sparse)"
# The copy in upstream/ stays until the new one is complete: a fetch that fails (offline, a bad pin)
# leaves the install that worked.
rm -rf upstream.partial
git init -q upstream.partial
git -C upstream.partial remote add origin "${UPSTREAM_REPO}"
# Split the patterns on spaces WITHOUT globbing: `/*` is a sparse pattern, not the filesystem root.
read -r -a patterns <<<"${UPSTREAM_SPARSE}"
git -C upstream.partial sparse-checkout set --"${UPSTREAM_SPARSE_MODE}" -- "${patterns[@]}"
git -C upstream.partial fetch -q --depth 1 --filter=blob:none origin "${UPSTREAM_COMMIT}"
git -C upstream.partial checkout -q FETCH_HEAD
echo "${UPSTREAM_COMMIT}" > upstream.partial/.harness-commit
rm -rf upstream
mv upstream.partial upstream
echo "ok   ${UPSTREAM_NAME} @ ${UPSTREAM_COMMIT:0:12} fetched ($(du -sh upstream | cut -f1))"