mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-09-21 05:54:18 +00:00
chore: add orb setup and resume hooks
Fresh Amp orbs start without a Rust toolchain or Nix, so every agent would repeat the same install. `.agents/setup` installs Nix (single-user), realizes the flake dev shell, activates it for the login shells Amp and orb services start, and warms target/ so the first agent command is incremental. `.agents/resume` re-checks the toolchain after a pause. Also ignore .amp/portals/ so orb runtime files stay out of git status. Amp-Thread-ID: https://ampcode.com/threads/T-01a0ba76-221d-728b-9d68-45ab48750d3d Co-authored-by: The Diligence Dev <thediligencedev@gmail.com>
This commit is contained in:
parent
d7222d54b5
commit
cbf5694441
3 changed files with 183 additions and 0 deletions
41
.agents/resume
Executable file
41
.agents/resume
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Orb resume for idx-cli.
|
||||
#
|
||||
# The repository has no services and no private registries, so nothing here
|
||||
# needs credentials. This verifies quickly that the snapshot's toolchain is
|
||||
# still usable after a pause, and restores the Nix flake config if it vanished.
|
||||
# Keep it fast: Amp waits at most 10 seconds.
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
nix_bin="$HOME/.nix-profile/bin/nix"
|
||||
nix_conf="$HOME/.config/nix/nix.conf"
|
||||
log="$HOME/.cache/amp/logs/resume-detail.log"
|
||||
|
||||
mkdir -p "$(dirname "$log")"
|
||||
log_line() { printf '%s idx-cli resume: %s\n' "$(date -Is)" "$*" >>"$log"; }
|
||||
|
||||
fail() {
|
||||
log_line "FAILED: $*"
|
||||
printf 'idx-cli orb: %s\nRepair it with %s/.agents/setup\n' "$*" "$repo_root" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ ! -x "$nix_bin" ]; then
|
||||
fail "Nix is not installed"
|
||||
fi
|
||||
|
||||
if ! grep -qE '^[[:space:]]*experimental-features[[:space:]]*=.*nix-command' "$nix_conf" 2>/dev/null; then
|
||||
mkdir -p "$(dirname "$nix_conf")"
|
||||
printf 'experimental-features = nix-command flakes\n' >>"$nix_conf"
|
||||
log_line "restored $nix_conf"
|
||||
fi
|
||||
|
||||
# The toolchain has to be on PATH in a clean login shell: that is the
|
||||
# environment Amp's executor and supervised orb services inherit.
|
||||
if ! env -i HOME="$HOME" USER="${USER:-user}" PATH=/usr/bin:/bin /bin/bash -lc 'command -v cargo >/dev/null 2>&1'; then
|
||||
fail "cargo is not on PATH in a clean login shell"
|
||||
fi
|
||||
|
||||
log_line "ok"
|
||||
Loading…
Add table
Add a link
Reference in a new issue