From 8674283ef2a8a0c316792c9dffb3c3c67243a917 Mon Sep 17 00:00:00 2001 From: Amp Date: Tue, 15 Sep 2026 18:07:36 +0000 Subject: [PATCH] chore: add Amp orb setup/resume scripts Give future orbs a fast, idempotent Rust toolchain path and ignore local portal files so agents can build in-cli without manual rustup. Amp-Thread-ID: https://ampcode.com/threads/T-01a0a631-f6de-735d-b395-b45d281f927e Co-authored-by: Max Carter --- .agents/resume | 13 +++++++++++ .agents/setup | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 3 +++ 3 files changed, 76 insertions(+) create mode 100755 .agents/resume create mode 100755 .agents/setup diff --git a/.agents/resume b/.agents/resume new file mode 100755 index 00000000..2be444b3 --- /dev/null +++ b/.agents/resume @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# Fast orb resume: ensure Rust is on PATH. Do not install packages here. +set -euo pipefail + +if [[ -f "${HOME}/.cargo/env" ]]; then + # shellcheck disable=SC1091 + source "${HOME}/.cargo/env" +fi + +if ! command -v rustc >/dev/null 2>&1 || ! command -v cargo >/dev/null 2>&1; then + echo "[resume] rustc/cargo missing; run .agents/setup" >&2 + exit 1 +fi diff --git a/.agents/setup b/.agents/setup new file mode 100755 index 00000000..6f5f4449 --- /dev/null +++ b/.agents/setup @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +# Idempotent orb setup for inauguration: Rust toolchain + in-cli lockfile fetch. +set -euo pipefail + +step() { + local label="$1" + shift + echo "[setup] ${label}" + local start + start="$(date +%s)" + "$@" + echo "[setup] ${label} ($(( $(date +%s) - start ))s)" +} + +need_pkg() { + dpkg -s "$1" >/dev/null 2>&1 +} + +missing=() +for pkg in build-essential pkg-config curl ca-certificates; do + need_pkg "$pkg" || missing+=("$pkg") +done +if ((${#missing[@]})); then + step "apt-get update" sudo apt-get update -qq + step "apt-get install" sudo apt-get install -y -qq "${missing[@]}" +fi + +export CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}" +export RUSTUP_HOME="${RUSTUP_HOME:-$HOME/.rustup}" +export PATH="${CARGO_HOME}/bin:${PATH}" + +if ! command -v rustup >/dev/null 2>&1; then + step "install rustup" bash -c 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile default --component rustfmt,clippy,rust-src' +fi + +# shellcheck disable=SC1091 +source "${CARGO_HOME}/env" + +step "rustup default stable" rustup default stable +step "rustup components" rustup component add rustfmt clippy rust-src + +profile_marker="# inauguration rustup" +if ! grep -Fqx "$profile_marker" "$HOME/.bash_profile" 2>/dev/null; then + cat >> "$HOME/.bash_profile" <