mirror of
https://github.com/boshu2/agentops.git
synced 2026-09-14 15:08:13 +08:00
130 lines
3.7 KiB
Bash
Executable File
130 lines
3.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# install-codex.sh — Legacy Codex plugin-cache compatibility installer.
|
|
# New installs should clone AgentOps and run `ao skills link`.
|
|
#
|
|
# Usage:
|
|
# curl -fsSL https://raw.githubusercontent.com/boshu2/agentops/main/scripts/install-codex.sh | bash
|
|
# curl -fsSL https://raw.githubusercontent.com/boshu2/agentops/main/scripts/install-codex.sh | bash -s -- --with-hooks
|
|
#
|
|
# What it does:
|
|
# 1. Downloads a temporary AgentOps archive (no local git clone)
|
|
# 2. Builds the generated Codex-native skill bundle
|
|
# 3. Refreshes the native Codex plugin cache in ~/.codex/plugins/cache
|
|
# 4. Archives stale raw skill mirrors in ~/.agents/skills and ~/.codex/skills when found
|
|
# 5. Enables the plugin in ~/.codex/config.toml
|
|
#
|
|
# Update policy:
|
|
# Re-run this installer when new AgentOps releases land.
|
|
|
|
set -euo pipefail
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[0;33m'
|
|
NC='\033[0m'
|
|
|
|
info() { echo -e "${GREEN}✓${NC} $*"; }
|
|
warn() { echo -e "${YELLOW}!${NC} $*"; }
|
|
fail() { echo -e "${RED}✗${NC} $*"; exit 1; }
|
|
|
|
UPDATE_CMD="curl -fsSL https://raw.githubusercontent.com/boshu2/agentops/main/scripts/install-codex.sh | bash"
|
|
SOURCE_ROOT_OVERRIDE="${AGENTOPS_BUNDLE_ROOT:-}"
|
|
INSTALL_REF="${AGENTOPS_INSTALL_REF:-main}"
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
install-codex.sh
|
|
|
|
Install AgentOps into the local Codex native plugin cache.
|
|
|
|
DEPRECATED: retained for 3.x migration compatibility. New installs should use
|
|
one canonical checkout plus `ao skills link`.
|
|
|
|
Options:
|
|
--help Show this help
|
|
EOF
|
|
}
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--help|-h)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Unknown arg: $1" >&2
|
|
usage >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ "$INSTALL_REF" == "main" ]]; then
|
|
ARCHIVE_URL="https://codeload.github.com/boshu2/agentops/tar.gz/refs/heads/main"
|
|
else
|
|
ARCHIVE_URL="https://codeload.github.com/boshu2/agentops/tar.gz/refs/tags/$INSTALL_REF"
|
|
fi
|
|
|
|
echo "Installing AgentOps for Codex..."
|
|
echo ""
|
|
|
|
for cmd in curl tar; do
|
|
if ! command -v "$cmd" >/dev/null 2>&1; then
|
|
fail "Missing required command: $cmd"
|
|
fi
|
|
done
|
|
|
|
if ! command -v codex >/dev/null 2>&1; then
|
|
warn "Codex CLI not found in PATH. Install from https://github.com/openai/codex"
|
|
warn "Continuing anyway — skills will be ready when Codex is installed."
|
|
fi
|
|
|
|
TMP_DIR="$(mktemp -d)"
|
|
cleanup() { rm -rf "$TMP_DIR"; }
|
|
trap cleanup EXIT
|
|
|
|
if [[ -n "$SOURCE_ROOT_OVERRIDE" ]]; then
|
|
SRC_ROOT="$SOURCE_ROOT_OVERRIDE"
|
|
info "Using provided AgentOps bundle: $SRC_ROOT"
|
|
else
|
|
ARCHIVE_FILE="${TMP_DIR}/agentops.tar.gz"
|
|
info "Downloading AgentOps bundle..."
|
|
curl -fsSL "$ARCHIVE_URL" -o "$ARCHIVE_FILE"
|
|
|
|
tar -tzf "$ARCHIVE_FILE" > "${TMP_DIR}/archive-files.txt"
|
|
ARCHIVE_ROOT="$(awk -F/ 'NR == 1 { print $1 }' "${TMP_DIR}/archive-files.txt")"
|
|
[ -n "$ARCHIVE_ROOT" ] || fail "Could not determine archive root directory"
|
|
tar -xzf "$ARCHIVE_FILE" -C "$TMP_DIR"
|
|
SRC_ROOT="${TMP_DIR}/${ARCHIVE_ROOT}"
|
|
fi
|
|
|
|
[ -f "$SRC_ROOT/scripts/install-codex-plugin.sh" ] || fail "Native Codex installer not found in bundle"
|
|
|
|
# skills-codex/ is a generated projection shipped in the bundle.
|
|
|
|
BUNDLE_VERSION="$INSTALL_REF"
|
|
if [[ -f "$SRC_ROOT/.codex-plugin/plugin.json" ]]; then
|
|
parsed_version="$(
|
|
sed -n 's/^[[:space:]]*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$SRC_ROOT/.codex-plugin/plugin.json" |
|
|
head -1
|
|
)"
|
|
if [[ -n "$parsed_version" ]]; then
|
|
BUNDLE_VERSION="$parsed_version"
|
|
fi
|
|
fi
|
|
|
|
plugin_args=(
|
|
--repo-root "$SRC_ROOT"
|
|
--version "$BUNDLE_VERSION"
|
|
--update-command "$UPDATE_CMD"
|
|
)
|
|
|
|
bash "$SRC_ROOT/scripts/install-codex-plugin.sh" "${plugin_args[@]}"
|
|
|
|
echo ""
|
|
echo "Update note:"
|
|
echo " AgentOps ships frequent updates."
|
|
echo " Re-run this installer regularly to pick up the latest main branch changes:"
|
|
echo " $UPDATE_CMD"
|