Files
gori-agent/gori-agent.sh
2026-08-17 00:49:29 +08:00

47 lines
848 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
usage() {
cat <<'EOF'
Usage: gori-agent <command> [arguments]
Commands:
init <bot-id>
setup <bot-id>
start <bot-id>
stop <bot-id>
restart <bot-id>
status <bot-id>
logs <bot-id>
doctor <bot-id>
list
Instances live under ${GORI_AGENT_ROOT:-$HOME/.gori-agent}/instances/<bot-id>.
config.example.json is documentation only and is never used as runtime config.
EOF
}
ensure_build() {
if [[ ! -f "$ROOT_DIR/dist/cli.js" || ! -f "$ROOT_DIR/dist/cli/instance-runner.js" ]]; then
echo "CLI build output not found; building..."
npm run build --prefix "$ROOT_DIR"
fi
}
if [[ $# -eq 0 ]]; then
usage
exit 1
fi
case "$1" in
--help|-h)
usage
exit 0
;;
esac
ensure_build
exec node "$ROOT_DIR/dist/cli.js" "$@"