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
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
unset AGENT_ID AGENT_WORKSPACE AGENT_VERIFY
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||||
PLUGINS_DIR="$PROJECT_ROOT/plugins"
|
PLUGINS_DIR="$PROJECT_ROOT/plugins"
|
||||||
ENV_FILE="$PROJECT_ROOT/.env"
|
ENV_FILE="$PROJECT_ROOT/.env"
|
||||||
|
GIT_BASE="https://git.hangman-lab.top"
|
||||||
|
|
||||||
# ── Helpers ──────────────────────────────────────────────────────────────────
|
# ── Helpers ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -53,6 +56,9 @@ Options:
|
|||||||
--uninstall Uninstall plugins instead of installing
|
--uninstall Uninstall plugins instead of installing
|
||||||
--skip-deps Skip npm install step
|
--skip-deps Skip npm install step
|
||||||
--skip-config Skip openclaw config set 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
|
-h, --help Show this help
|
||||||
|
|
||||||
Plugins: PaddedCell, ContractorAgent, Dirigent, HarborForge.OpenclawPlugin, Yonexus.Server
|
Plugins: PaddedCell, ContractorAgent, Dirigent, HarborForge.OpenclawPlugin, Yonexus.Server
|
||||||
@@ -68,6 +74,9 @@ EOF
|
|||||||
UNINSTALL=false
|
UNINSTALL=false
|
||||||
SKIP_DEPS=false
|
SKIP_DEPS=false
|
||||||
SKIP_CONFIG=false
|
SKIP_CONFIG=false
|
||||||
|
INSTALL_CLI_BRANCH=""
|
||||||
|
YONEXUS_CLIENT_BRANCH=""
|
||||||
|
YONEXUS_PROTOCOL_BRANCH=""
|
||||||
SELECTED_PLUGINS=()
|
SELECTED_PLUGINS=()
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
@@ -77,6 +86,9 @@ while [[ $# -gt 0 ]]; do
|
|||||||
--uninstall) UNINSTALL=true; shift ;;
|
--uninstall) UNINSTALL=true; shift ;;
|
||||||
--skip-deps) SKIP_DEPS=true; shift ;;
|
--skip-deps) SKIP_DEPS=true; shift ;;
|
||||||
--skip-config) SKIP_CONFIG=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 ;;
|
-h|--help) usage ;;
|
||||||
-*) err "Unknown option: $1"; usage ;;
|
-*) err "Unknown option: $1"; usage ;;
|
||||||
*) SELECTED_PLUGINS+=("$1"); shift ;;
|
*) SELECTED_PLUGINS+=("$1"); shift ;;
|
||||||
@@ -103,11 +115,55 @@ cd "$PROJECT_ROOT"
|
|||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
ok "Submodules ready"
|
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 ─────────────────────────────────────────────────────
|
# ── Resolve plugin list ─────────────────────────────────────────────────────
|
||||||
|
|
||||||
ALL_PLUGINS=()
|
ALL_PLUGINS=()
|
||||||
for d in "$PLUGINS_DIR"/*/; do
|
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
|
done
|
||||||
|
|
||||||
if [[ ${#SELECTED_PLUGINS[@]} -eq 0 ]]; then
|
if [[ ${#SELECTED_PLUGINS[@]} -eq 0 ]]; then
|
||||||
@@ -150,13 +206,23 @@ find_install_script() {
|
|||||||
done
|
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() {
|
plugin_install_args() {
|
||||||
local name="$1" action="$2"
|
local name="$1" action="$2"
|
||||||
local args=("--$action")
|
local args=("--$action")
|
||||||
if [[ "$action" == "install" ]]; then
|
if [[ "$action" == "install" ]]; then
|
||||||
case "$name" in
|
case "$name" in
|
||||||
HarborForge.OpenclawPlugin)
|
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)
|
PaddedCell|Dirigent|Yonexus.Server)
|
||||||
args+=(--openclaw-profile-path ~/.openclaw)
|
args+=(--openclaw-profile-path ~/.openclaw)
|
||||||
@@ -267,6 +333,9 @@ run_plugin() {
|
|||||||
|
|
||||||
log "[install] $name"
|
log "[install] $name"
|
||||||
install_deps "$dir"
|
install_deps "$dir"
|
||||||
|
if [[ "$name" == "Yonexus.Server" ]]; then
|
||||||
|
build_yonexus
|
||||||
|
fi
|
||||||
run_install_script "$name" "$dir" "install" || return $?
|
run_install_script "$name" "$dir" "install" || return $?
|
||||||
configure_plugin "$name"
|
configure_plugin "$name"
|
||||||
ok "$name done"
|
ok "$name done"
|
||||||
|
|||||||
Reference in New Issue
Block a user