Files
boshu2__agentops/scripts/install-bd.sh
T
Bo 0f8dbee992 fix(nightly): ship 5 retrospective code fixes (truncate, standards gate, probed_stale_at, dream-probe, bd-install) (#156)
* fix(goals): preserve diagnostic tail in truncateOutput

Head-only truncation at 500 runes cut the operator hint off the end of
gate output. The 2026-04-26 nightly retrospective showed flywheel-
compounding's "sessions must use 'ao lookup --cite ...'" tail being lost
mid-word for verbose runs.

New shape: when input exceeds 500 runes, keep first 200 + truncation
marker + last 200 runes. Short inputs untouched. Verified against live
ao goals measure --json — six long-output gates (flywheel-proof,
hook-preflight, go-cli-tests, contract-compatibility, install-smoke,
flywheel-lifecycle) now expose both their failure label and their
trailing fix-it.

Source: 2026-04-26 nightly retro task 1.

* feat(ci): add standards-injector reference completeness gate

hooks/standards-injector.sh fails open when a mapped <lang> is missing
its reference file. That's how `.js` lost standards inject for weeks
until the 2026-04-26 nightly caught it. New gate parses the case
statement, asserts every mapped lang has skills/standards/references/
<lang>.md, and runs in pre-push and CI.

Wires:
- scripts/check-standards-injector-completeness.sh (new)
- scripts/pre-push-gate.sh (slot 27b under hook category)
- .github/workflows/validate.yml (parallel job + summary deps)
- tests/scripts/check-standards-injector-completeness.bats (6 cases:
  happy path, missing-named, |-alternation, parser-empty, real-repo)

Removing skills/standards/references/javascript.md temporarily makes
the gate FAIL with a clear message; restoring makes it PASS.

Source: 2026-04-26 nightly retro task 2.

* feat(rpi): add probed_stale_at + probed_by + ao rpi mark-probed

When a nightly probes a queue item and finds it stale, the knowledge
dies in the digest — tomorrow's run re-probes the same item. Adds
optional probed_stale_at (RFC3339) and probed_by fields to the v1.3
item schema, the Go round-trip type, the schema-rows acceptance test,
and a new `ao rpi mark-probed --id=... --by=...` subcommand for future
nightlies to write these without hand-editing JSON.

- docs/contracts/next-work.schema.md (Item table)
- cli/internal/rpi/types.go (NextWorkItem fields, omitempty)
- cli/internal/rpi/types_test.go (round-trip + omitempty)
- cli/cmd/ao/rpi_mark_probed.go (new subcommand)
- cli/cmd/ao/rpi_mark_probed_test.go (4 cases)
- cli/docs/COMMANDS.md (regenerated)
- tests/scripts/check-next-work-schema-rows.bats (acceptance case)

validate-next-work-contract-parity.sh stays green.

Source: 2026-04-26 nightly retro task 3.

* fix(overnight): probe Dream packets for staleness before emit

Three nightlies in a row emitted the same two stale packets ("philosophy
doc", "next-work schema v1.3") because no gate verified the cited
surface wasn't already shipped. Curator now runs a 5-second tractability
probe against each candidate's TargetFiles + scripts/ refs in the
morning command before writing it. Conclusively-stale packets are
suppressed; the suppression is recorded as a dream-curator-suppressed
entry on the run summary so operators see what was skipped instead of a
silent gap.

- cli/cmd/ao/overnight.go (overnightSummary.CuratorSuppressed)
- cli/cmd/ao/overnight_packets.go (probeDreamPacketStaleness,
  extractScriptsRef, suppression plumbed through
  buildDreamMorningPacketPlans return)
- cli/cmd/ao/overnight_packets_test.go (suppression-on-existing-target +
  emits-when-inconclusive integration tests)

Source: 2026-04-26 nightly retro task 4.

* chore(scripts): add install-bd.sh installer

bd has been "unavailable" in three consecutive nightly runs. Upstream
(steveyegge/beads) publishes signed cross-platform binaries for
darwin/linux on amd64/arm64. New installer detects the platform,
downloads the matching tarball, installs to ~/.local/bin/bd, and
verifies via `bd version`. Idempotent: short-circuits when the
requested version is already present (use --force to override).

- scripts/install-bd.sh (new, executable)
- tests/scripts/install-bd.bats (4 offline-safe cases)

Verified end-to-end on darwin/arm64: download + extract + verify all
green.

Source: 2026-04-26 nightly retro task 5.

* fix(ci): align bats stub and AGENTS table with new standards-injector gate

PR #156 introduced scripts/check-standards-injector-completeness.sh
without:
- adding a make_stub for it in tests/scripts/pre-push-gate.bats setup;
  three pre-push-gate bats tests (404, 414, 415) used a FAKE_REPO that
  lacked the new script and the gate fired "missing executable", so
  status came back non-zero
- listing it in the AGENTS.md CI table; validate-ci-policy-parity.sh
  diffs the table against validate.yml summary.needs and flagged 2
  drift groups

Both gates pass locally now.
2026-04-26 19:26:04 -04:00

143 lines
4.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# install-bd.sh — install the `bd` (beads) CLI to ~/.local/bin/bd.
#
# Beads has been "unavailable" in three consecutive nightly runs (2026-04-26
# retro task 5). Upstream publishes signed binaries for darwin/linux/windows
# under https://github.com/steveyegge/beads/releases. This script detects the
# platform, downloads the matching tarball, and verifies the binary launches.
#
# Idempotent: re-running with bd already on PATH at the requested version is
# a no-op (exit 0). Use --force to redownload.
#
# Examples:
# scripts/install-bd.sh # install latest tagged release
# scripts/install-bd.sh --version v1.0.3 # pin a version
# scripts/install-bd.sh --force # redownload even if installed
#
# Exit codes:
# 0 bd installed (or already present at the requested version)
# 1 download or extraction failed
# 2 unsupported platform / arch
# 3 verification failed (binary did not launch)
set -euo pipefail
REPO="steveyegge/beads"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
VERSION=""
FORCE=0
usage() {
sed -n '2,/^$/p' "$0" | sed 's/^# \{0,1\}//'
}
while [[ $# -gt 0 ]]; do
case "$1" in
--version) VERSION="$2"; shift 2 ;;
--force) FORCE=1; shift ;;
--install-dir) INSTALL_DIR="$2"; shift 2 ;;
-h|--help) usage; exit 0 ;;
*) echo "unknown flag: $1" >&2; exit 1 ;;
esac
done
# --- detect platform ---
uname_s="$(uname -s)"
uname_m="$(uname -m)"
case "$uname_s" in
Darwin) os="darwin" ;;
Linux) os="linux" ;;
*) echo "unsupported OS: $uname_s" >&2; exit 2 ;;
esac
case "$uname_m" in
x86_64|amd64) arch="amd64" ;;
arm64|aarch64) arch="arm64" ;;
*) echo "unsupported arch: $uname_m" >&2; exit 2 ;;
esac
# --- resolve version ---
if [[ -z "$VERSION" ]]; then
if ! command -v curl >/dev/null 2>&1; then
echo "curl is required to resolve latest version" >&2
exit 1
fi
VERSION="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \
| sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p' | head -1)"
if [[ -z "$VERSION" ]]; then
echo "could not resolve latest beads release tag" >&2
exit 1
fi
fi
# --- short-circuit if already installed at the requested version ---
if [[ "$FORCE" -eq 0 ]] && command -v bd >/dev/null 2>&1; then
have="$(bd version 2>&1 | head -1 || true)"
# bd version output is like "bd version 1.0.3 (Homebrew)"
if [[ "$have" == *"${VERSION#v}"* ]]; then
echo "bd ${VERSION} already installed at $(command -v bd) — skipping (--force to override)"
exit 0
fi
fi
# --- download and extract ---
ver_no_v="${VERSION#v}"
asset="beads_${ver_no_v}_${os}_${arch}.tar.gz"
url="https://github.com/${REPO}/releases/download/${VERSION}/${asset}"
tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT
echo "downloading $url"
if ! curl -fsSL "$url" -o "$tmp_dir/$asset"; then
echo "download failed: $url" >&2
exit 1
fi
echo "extracting $asset"
if ! tar -xzf "$tmp_dir/$asset" -C "$tmp_dir"; then
echo "extraction failed" >&2
exit 1
fi
# --- find the bd binary in the extracted tree ---
binary=""
for candidate in "$tmp_dir/bd" "$tmp_dir/beads" "$tmp_dir"/*/bd "$tmp_dir"/*/beads; do
if [[ -f "$candidate" && -x "$candidate" ]]; then
binary="$candidate"
break
fi
done
if [[ -z "$binary" ]]; then
echo "could not locate bd binary in tarball" >&2
ls -R "$tmp_dir" >&2
exit 1
fi
# --- install ---
mkdir -p "$INSTALL_DIR"
target="$INSTALL_DIR/bd"
cp "$binary" "$target"
chmod +x "$target"
echo "installed bd to $target"
# --- verify ---
if ! "$target" version >/dev/null 2>&1; then
echo "verification failed: $target version did not launch" >&2
exit 3
fi
actual="$("$target" version 2>&1 | head -1)"
echo "verified: $actual"
# --- PATH hint ---
case ":$PATH:" in
*":$INSTALL_DIR:"*) ;;
*)
echo
echo "note: $INSTALL_DIR is not on \$PATH. Add this to your shell rc:"
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
;;
esac
exit 0