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