#!/bin/bash
set -euo pipefail

apt-get update
apt-get install -y curl git ripgrep xz-utils

# Install hermes-agent using the official installer (handles Python, Node.js, deps)
{% if version %}
curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash -s -- --skip-setup --branch {{ version }}
{% else %}
curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash -s -- --skip-setup
{% endif %}

export PATH="$HOME/.local/bin:$PATH"

# Create hermes config directory structure
export HERMES_HOME="${HERMES_HOME:-/tmp/hermes}"
mkdir -p "$HERMES_HOME" "$HERMES_HOME/sessions" "$HERMES_HOME/skills" "$HERMES_HOME/memories"

hermes version
