Files
buzz/scripts/bundle-sidecars.sh
Michael Neale 0f92884043 feat: bundle a slim goose agent (goose-acp) as a desktop sidecar
Adds goose-acp/, a workspace-excluded crate that builds goose's ACP
stdio server from the goose library crate with default-features off
(rustls-tls only): no code-mode/V8, no local-inference/llama.cpp, no
keyring/AWS/telemetry, no goose CLI. Full agent loop, providers,
sessions, and MCP extensions intact. ~32 MB on macOS arm64 (~9 MB
added to the compressed download) vs ~240 MB for a stock goose
install; drops to ~14 MB once goose's analyze/tiktoken feature gates
land upstream and the rev pin is bumped.

Workspace exclusion is deliberate: goose's ~700-crate graph stays out
of the workspace lockfile, and rmcp stays pinned at 1.7.0 (goose does
not compile against 1.8) in goose-acp's own Cargo.lock.

Wiring:
- buzz-acp: goose-acp identity takes no 'acp' subcommand (it is
  already the ACP server), with tests
- desktop: goose runtime discovery also accepts goose-acp, so the
  bundled sidecar is found when no user-installed goose exists;
  orphan sweep already matches it via the goose- prefix rule
- packaging: tauri externalBin entry, sidecar stubs (justfile + CI),
  bundle-sidecars.sh stages it when built, release workflow builds it
  for all targets
2026-07-06 10:20:50 -07:00

61 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SIDECARS=(buzz-acp buzz-agent buzz-dev-mcp git-credential-nostr buzz)
# goose-acp lives outside the workspace (own lockfile — see goose-acp/Cargo.toml)
# so it builds into its own target dir and is staged separately below.
GOOSE_ACP_DIR="goose-acp"
HOST=$(rustc -vV | sed -n 's|host: ||p')
TARGET=${1:-$HOST}
BINARIES_DIR="desktop/src-tauri/binaries"
# When --target is passed explicitly to cargo (even if it matches the host),
# binaries land in target/<triple>/release/. Without --target, they land in
# target/release/. The script receives the target as $1 only when cargo was
# invoked with --target, so use the qualified path whenever $1 is set.
if [[ -n "${1:-}" ]]; then
SRC_DIR="target/${TARGET}/release"
else
SRC_DIR="target/release"
fi
# MSVC emits <name>.exe; Tauri's externalBin then expects binaries/<name>-<triple>.exe.
if [[ "$TARGET" == *windows* ]]; then
EXE=".exe"
else
EXE=""
fi
missing=()
for bin in "${SIDECARS[@]}"; do
[[ -f "$SRC_DIR/${bin}${EXE}" ]] || missing+=("${bin}${EXE}")
done
if [[ ${#missing[@]} -gt 0 ]]; then
echo "Error: missing release binaries in $SRC_DIR: ${missing[*]}" >&2
echo "Run 'cargo build --release -p buzz-acp -p buzz-agent -p buzz-dev-mcp -p git-credential-nostr -p buzz-cli' first." >&2
exit 1
fi
mkdir -p "$BINARIES_DIR"
for bin in "${SIDECARS[@]}"; do
cp "$SRC_DIR/${bin}${EXE}" "$BINARIES_DIR/${bin}-${TARGET}${EXE}"
done
# Bundled slim goose ACP agent (optional today: staged only when built, so
# local flows that skip it keep working; CI builds it explicitly).
if [[ -n "${1:-}" ]]; then
GOOSE_ACP_SRC="$GOOSE_ACP_DIR/target/${TARGET}/release/goose-acp${EXE}"
else
GOOSE_ACP_SRC="$GOOSE_ACP_DIR/target/release/goose-acp${EXE}"
fi
if [[ -f "$GOOSE_ACP_SRC" ]]; then
cp "$GOOSE_ACP_SRC" "$BINARIES_DIR/goose-acp-${TARGET}${EXE}"
# cp onto an existing stub (touched by _ensure-sidecar-stubs) keeps the
# stub's non-executable mode — restore it explicitly.
chmod +x "$BINARIES_DIR/goose-acp-${TARGET}${EXE}"
echo "Bundled goose-acp"
else
echo "Note: goose-acp not built ($GOOSE_ACP_SRC missing); skipping." >&2
fi
echo "Sidecars bundled for $TARGET"