setup-plugins: clone external deps from git, unset AGENT_* vars
- unset AGENT_ID/AGENT_WORKSPACE/AGENT_VERIFY so plugin installers don't refuse operations gated to human-only - --install-cli <branch>: shallow-clone HarborForge.Cli to tmp, symlink into plugins/ for the install script to find - --yonexus-client/--yonexus-protocol <branch>: same pattern for Yonexus.Client and Yonexus.Protocol (needed for tsc build) - build_yonexus step runs tsc before Yonexus.Server install - cloned repos and symlinks cleaned up on EXIT trap - --install-cli only passed to HarborForge when the flag is given
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
unset AGENT_ID AGENT_WORKSPACE AGENT_VERIFY
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
PLUGINS_DIR="$PROJECT_ROOT/plugins"
|
||||
ENV_FILE="$PROJECT_ROOT/.env"
|
||||
GIT_BASE="https://git.hangman-lab.top"
|
||||
|
||||
# ── Helpers ──────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -48,12 +51,15 @@ Install and configure OpenClaw plugins from the plugins/ directory.
|
||||
If no plugin names are given, all plugins are processed.
|
||||
|
||||
Options:
|
||||
--env <path> Path to .env file (default: <project-root>/.env)
|
||||
--list List available plugins and exit
|
||||
--uninstall Uninstall plugins instead of installing
|
||||
--skip-deps Skip npm install step
|
||||
--skip-config Skip openclaw config set step
|
||||
-h, --help Show this help
|
||||
--env <path> Path to .env file (default: <project-root>/.env)
|
||||
--list List available plugins and exit
|
||||
--uninstall Uninstall plugins instead of installing
|
||||
--skip-deps Skip npm install step
|
||||
--skip-config Skip openclaw config set step
|
||||
--install-cli <branch> Clone & build HarborForge.Cli (default: main)
|
||||
--yonexus-client <branch> Clone Yonexus.Client for build (default: main)
|
||||
--yonexus-protocol <branch> Clone Yonexus.Protocol for build (default: main)
|
||||
-h, --help Show this help
|
||||
|
||||
Plugins: PaddedCell, ContractorAgent, Dirigent, HarborForge.OpenclawPlugin, Yonexus.Server
|
||||
|
||||
@@ -68,18 +74,24 @@ EOF
|
||||
UNINSTALL=false
|
||||
SKIP_DEPS=false
|
||||
SKIP_CONFIG=false
|
||||
INSTALL_CLI_BRANCH=""
|
||||
YONEXUS_CLIENT_BRANCH=""
|
||||
YONEXUS_PROTOCOL_BRANCH=""
|
||||
SELECTED_PLUGINS=()
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--env) ENV_FILE="$2"; shift 2 ;;
|
||||
--list) ls "$PLUGINS_DIR"; exit 0 ;;
|
||||
--uninstall) UNINSTALL=true; shift ;;
|
||||
--skip-deps) SKIP_DEPS=true; shift ;;
|
||||
--skip-config) SKIP_CONFIG=true; shift ;;
|
||||
-h|--help) usage ;;
|
||||
-*) err "Unknown option: $1"; usage ;;
|
||||
*) SELECTED_PLUGINS+=("$1"); shift ;;
|
||||
--env) ENV_FILE="$2"; shift 2 ;;
|
||||
--list) ls "$PLUGINS_DIR"; exit 0 ;;
|
||||
--uninstall) UNINSTALL=true; shift ;;
|
||||
--skip-deps) SKIP_DEPS=true; shift ;;
|
||||
--skip-config) SKIP_CONFIG=true; shift ;;
|
||||
--install-cli) INSTALL_CLI_BRANCH="${2:-main}"; shift 2 ;;
|
||||
--yonexus-client) YONEXUS_CLIENT_BRANCH="${2:-main}"; shift 2 ;;
|
||||
--yonexus-protocol) YONEXUS_PROTOCOL_BRANCH="${2:-main}"; shift 2 ;;
|
||||
-h|--help) usage ;;
|
||||
-*) err "Unknown option: $1"; usage ;;
|
||||
*) SELECTED_PLUGINS+=("$1"); shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
@@ -103,11 +115,55 @@ cd "$PROJECT_ROOT"
|
||||
git submodule update --init --recursive
|
||||
ok "Submodules ready"
|
||||
|
||||
# ── Clone external deps to tmp ──────────────────────────────────────────────
|
||||
|
||||
TMPDIR_CLONES=""
|
||||
SYMLINKS_TO_CLEAN=()
|
||||
|
||||
clone_dep() {
|
||||
local org="$1" repo="$2" branch="$3" target_link="$4"
|
||||
if [[ -z "$TMPDIR_CLONES" ]]; then
|
||||
TMPDIR_CLONES="$(mktemp -d)"
|
||||
fi
|
||||
local dest="$TMPDIR_CLONES/$repo"
|
||||
log "Cloning $org/$repo@$branch → $dest"
|
||||
git clone --depth 1 --branch "$branch" "$GIT_BASE/$org/$repo.git" "$dest" 2>&1 | tail -2
|
||||
ln -sfn "$dest" "$target_link"
|
||||
SYMLINKS_TO_CLEAN+=("$target_link")
|
||||
ok "$repo@$branch ready"
|
||||
}
|
||||
|
||||
cleanup_clones() {
|
||||
for link in "${SYMLINKS_TO_CLEAN[@]}"; do
|
||||
rm -f "$link"
|
||||
done
|
||||
if [[ -n "$TMPDIR_CLONES" ]]; then
|
||||
rm -rf "$TMPDIR_CLONES"
|
||||
fi
|
||||
}
|
||||
trap cleanup_clones EXIT
|
||||
|
||||
if [[ -n "$INSTALL_CLI_BRANCH" ]]; then
|
||||
clone_dep "zhi" "HarborForge.Cli" "$INSTALL_CLI_BRANCH" "$PLUGINS_DIR/HarborForge.Cli"
|
||||
fi
|
||||
|
||||
if [[ -n "$YONEXUS_CLIENT_BRANCH" ]]; then
|
||||
clone_dep "nav" "Yonexus.Client" "$YONEXUS_CLIENT_BRANCH" "$PLUGINS_DIR/Yonexus.Client"
|
||||
fi
|
||||
|
||||
if [[ -n "$YONEXUS_PROTOCOL_BRANCH" ]]; then
|
||||
clone_dep "nav" "Yonexus.Protocol" "$YONEXUS_PROTOCOL_BRANCH" "$PLUGINS_DIR/Yonexus.Protocol"
|
||||
fi
|
||||
|
||||
# ── Resolve plugin list ─────────────────────────────────────────────────────
|
||||
|
||||
ALL_PLUGINS=()
|
||||
for d in "$PLUGINS_DIR"/*/; do
|
||||
ALL_PLUGINS+=("$(basename "$d")")
|
||||
name="$(basename "$d")"
|
||||
case "$name" in
|
||||
HarborForge.Cli|Yonexus.Client|Yonexus.Protocol) continue ;;
|
||||
esac
|
||||
ALL_PLUGINS+=("$name")
|
||||
done
|
||||
|
||||
if [[ ${#SELECTED_PLUGINS[@]} -eq 0 ]]; then
|
||||
@@ -150,13 +206,23 @@ find_install_script() {
|
||||
done
|
||||
}
|
||||
|
||||
build_yonexus() {
|
||||
local dir="$PLUGINS_DIR/Yonexus.Server"
|
||||
log " Building Yonexus.Server (tsc)"
|
||||
(cd "$dir" && npm run build 2>&1 | tail -5)
|
||||
ok "Yonexus.Server built"
|
||||
}
|
||||
|
||||
plugin_install_args() {
|
||||
local name="$1" action="$2"
|
||||
local args=("--$action")
|
||||
if [[ "$action" == "install" ]]; then
|
||||
case "$name" in
|
||||
HarborForge.OpenclawPlugin)
|
||||
args+=(--install-cli --install-monitor yes --openclaw-profile-path ~/.openclaw)
|
||||
if [[ -n "$INSTALL_CLI_BRANCH" ]]; then
|
||||
args+=(--install-cli)
|
||||
fi
|
||||
args+=(--install-monitor yes --openclaw-profile-path ~/.openclaw)
|
||||
;;
|
||||
PaddedCell|Dirigent|Yonexus.Server)
|
||||
args+=(--openclaw-profile-path ~/.openclaw)
|
||||
@@ -267,6 +333,9 @@ run_plugin() {
|
||||
|
||||
log "[install] $name"
|
||||
install_deps "$dir"
|
||||
if [[ "$name" == "Yonexus.Server" ]]; then
|
||||
build_yonexus
|
||||
fi
|
||||
run_install_script "$name" "$dir" "install" || return $?
|
||||
configure_plugin "$name"
|
||||
ok "$name done"
|
||||
|
||||
Reference in New Issue
Block a user