Skip to content

Instantly share code, notes, and snippets.

@crueber
Created April 6, 2026 17:36
Show Gist options
  • Select an option

  • Save crueber/a7a8cb586f5eee09ff668cbc9e9ba7c2 to your computer and use it in GitHub Desktop.

Select an option

Save crueber/a7a8cb586f5eee09ff668cbc9e9ba7c2 to your computer and use it in GitHub Desktop.
Hermes CLI utility scripts for managing Docker-based development environments
#!/usr/bin/env bash
# hermes-cli - Run the Hermes Agent in interactive CLI mode
# Starts a temporary container for chatting with the agent interactively.
set -euo pipefail
HERMES_IMAGE="nousresearch/hermes-agent:latest"
HERMES_CONTAINER="hermes"
HERMES_DATA_DIR="${HOME}/.hermes"
require() {
command -v "$1" >/dev/null 2>&1 || { echo "Error: '$1' not found" >&2; exit 1; }
}
main() {
require docker
# Ensure data directory exists
if [[ ! -d "$HERMES_DATA_DIR" ]]; then
echo "Creating Hermes data directory: $HERMES_DATA_DIR"
mkdir -p "$HERMES_DATA_DIR"
fi
echo "Starting Hermes Agent CLI (interactive mode)..."
echo "Type 'exit' or press Ctrl+D to quit."
echo ""
docker run -it --rm --platform linux/amd64 \
-v "$HERMES_DATA_DIR:/opt/data" \
"$HERMES_IMAGE"
}
main "$@"
#!/usr/bin/env bash
# hermes-logs - View logs from the Hermes Agent container
# Shows the last 50 lines and follows new output.
set -euo pipefail
HERMES_CONTAINER="hermes"
HERMES_DATA_DIR="${HOME}/.hermes"
require() {
command -v "$1" >/dev/null 2>&1 || { echo "Error: '$1' not found" >&2; exit 1; }
}
main() {
require docker
# Check if container exists
if ! docker ps -a --format '{{.Names}}' | grep -q "^${HERMES_CONTAINER}$"; then
echo "Hermes container not found." >&2
echo "Use 'hermes-start' to start the agent first." >&2
exit 1
fi
echo "Showing logs for Hermes container (Ctrl+C to exit)..."
echo ""
docker logs --tail 50 -f "$HERMES_CONTAINER"
}
main "$@"
#!/usr/bin/env bash
# hermes-setup - Run the Hermes Agent setup wizard
# Creates the data directory and runs the interactive setup container.
set -euo pipefail
HERMES_IMAGE="nousresearch/hermes-agent:latest"
HERMES_CONTAINER="hermes"
HERMES_DATA_DIR="${HOME}/.hermes"
require() {
command -v "$1" >/dev/null 2>&1 || { echo "Error: '$1' not found" >&2; exit 1; }
}
main() {
require docker
if [[ ! -d "$HERMES_DATA_DIR" ]]; then
echo "Creating Hermes data directory: $HERMES_DATA_DIR"
mkdir -p "$HERMES_DATA_DIR"
fi
echo "Pulling Hermes Agent image (using AMD64 emulation if needed)..."
docker pull --platform linux/amd64 "$HERMES_IMAGE"
echo ""
echo "Running Hermes Agent setup wizard..."
echo "Follow the prompts to configure your agent."
echo ""
docker run -it --rm --platform linux/amd64 \
-v "$HERMES_DATA_DIR:/opt/data" \
"$HERMES_IMAGE" setup
echo ""
echo "Setup complete! Your configuration is stored in: $HERMES_DATA_DIR"
echo "You can now start the agent with: hermes-start"
}
main "$@"
#!/usr/bin/env bash
# hermes-shell - Open an interactive shell in the Hermes Agent container
# Useful for debugging and manual configuration.
set -euo pipefail
HERMES_CONTAINER="hermes"
HERMES_DATA_DIR="${HOME}/.hermes"
require() {
command -v "$1" >/dev/null 2>&1 || { echo "Error: '$1' not found" >&2; exit 1; }
}
main() {
require docker
# Check if container exists and is running
if ! docker ps --format '{{.Names}}' | grep -q "^${HERMES_CONTAINER}$"; then
echo "Hermes container is not running." >&2
echo "Use 'hermes-start' to start the agent first." >&2
exit 1
fi
echo "Opening shell in Hermes container (type 'exit' to leave)..."
echo ""
docker exec -it "$HERMES_CONTAINER" /bin/bash
}
main "$@"
#!/usr/bin/env bash
# hermes-start - Start the Hermes Agent container in gateway mode
# Runs the container with resource limits and auto-restart enabled.
set -euo pipefail
HERMES_IMAGE="nousresearch/hermes-agent:latest"
HERMES_CONTAINER="hermes"
HERMES_DATA_DIR="${HOME}/.hermes"
require() {
command -v "$1" >/dev/null 2>&1 || { echo "Error: '$1' not found" >&2; exit 1; }
}
main() {
require docker
# Check if container already exists
if docker ps -a --format '{{.Names}}' | grep -q "^${HERMES_CONTAINER}$"; then
if docker ps --format '{{.Names}}' | grep -q "^${HERMES_CONTAINER}$"; then
echo "Hermes container is already running." >&2
echo "Use 'hermes-logs' to view logs or 'hermes-shell' to access the container." >&2
exit 0
else
echo "Hermes container exists but is stopped. Removing old container..."
docker rm -f "$HERMES_CONTAINER" >/dev/null 2>&1 || true
fi
fi
# Ensure data directory exists
if [[ ! -d "$HERMES_DATA_DIR" ]]; then
echo "Creating Hermes data directory: $HERMES_DATA_DIR"
mkdir -p "$HERMES_DATA_DIR"
fi
echo "Starting Hermes Agent container..."
docker run -d --platform linux/amd64 \
--name "$HERMES_CONTAINER" \
--restart unless-stopped \
--memory=4g \
--cpus=2 \
--shm-size=1g \
-v "$HERMES_DATA_DIR:/opt/data" \
"$HERMES_IMAGE" gateway run
echo ""
echo "Hermes Agent started successfully!"
echo "Container: $HERMES_CONTAINER"
echo "Data directory: $HERMES_DATA_DIR"
echo ""
echo "Use 'hermes-logs' to view logs"
echo "Use 'hermes-status' to check status"
echo "Use 'hermes-stop' to stop the container"
}
main "$@"
#!/usr/bin/env bash
# hermes-status - Check the status of the Hermes Agent container
# Shows container state, uptime, and resource usage.
set -euo pipefail
HERMES_CONTAINER="hermes"
HERMES_DATA_DIR="${HOME}/.hermes"
require() {
command -v "$1" >/dev/null 2>&1 || { echo "Error: '$1' not found" >&2; exit 1; }
}
main() {
require docker
echo "Hermes Agent Status"
echo "==================="
echo ""
# Check if container exists
if ! docker ps -a --format '{{.Names}}' | grep -q "^${HERMES_CONTAINER}$"; then
echo "Container: Not created"
echo "Status: Not running"
echo ""
echo "Use 'hermes-start' to start the agent."
exit 0
fi
# Get container status
local status
status=$(docker inspect -f '{{.State.Status}}' "$HERMES_CONTAINER" 2>/dev/null || echo "unknown")
echo "Container: $HERMES_CONTAINER"
echo "Status: $status"
if [[ "$status" == "running" ]]; then
local started_at
started_at=$(docker inspect -f '{{.State.StartedAt}}' "$HERMES_CONTAINER")
# Calculate uptime (simplified)
echo "Started: $started_at"
echo ""
echo "Resource Usage:"
docker stats --no-stream --format \
" CPU: {{.CPUPerc}}\n Memory: {{.MemUsage}} ({{.MemPerc}})" \
"$HERMES_CONTAINER" 2>/dev/null || echo " (unable to retrieve stats)"
echo ""
echo "Ports:"
docker inspect -f '{{range $p, $conf := .NetworkSettings.Ports}}{{$p}} -> {{(index $conf 0).HostPort}}{{println}}{{end}}' "$HERMES_CONTAINER" 2>/dev/null | grep -v '^$' || echo " (no exposed ports)"
else
local exit_code
exit_code=$(docker inspect -f '{{.State.ExitCode}}' "$HERMES_CONTAINER" 2>/dev/null || echo "unknown")
echo "Exit Code: $exit_code"
echo ""
echo "Use 'hermes-logs' to see why the container stopped."
echo "Use 'hermes-start' to restart the agent."
fi
echo ""
echo "Data Directory: $HERMES_DATA_DIR"
}
main "$@"
#!/usr/bin/env bash
# hermes-stop - Stop and remove the Hermes Agent container
# Gracefully handles case where container doesn't exist.
set -euo pipefail
HERMES_IMAGE="nousresearch/hermes-agent:latest"
HERMES_CONTAINER="hermes"
HERMES_DATA_DIR="${HOME}/.hermes"
require() {
command -v "$1" >/dev/null 2>&1 || { echo "Error: '$1' not found" >&2; exit 1; }
}
main() {
require docker
# Check if container exists
if ! docker ps -a --format '{{.Names}}' | grep -q "^${HERMES_CONTAINER}$"; then
echo "Hermes container is not running (no container found)." >&2
exit 0
fi
echo "Stopping Hermes Agent container..."
docker stop "$HERMES_CONTAINER" >/dev/null 2>&1 || true
echo "Removing Hermes Agent container..."
docker rm -f "$HERMES_CONTAINER" >/dev/null 2>&1 || true
echo ""
echo "Hermes Agent stopped and removed."
echo "Your data is preserved in: $HERMES_DATA_DIR"
echo "Use 'hermes-start' to start the agent again."
}
main "$@"
#!/usr/bin/env bash
# hermes-upgrade - Upgrade the Hermes Agent to the latest version
# Pulls latest image, stops/removes existing container, and restarts.
set -euo pipefail
HERMES_IMAGE="nousresearch/hermes-agent:latest"
HERMES_CONTAINER="hermes"
HERMES_DATA_DIR="${HOME}/.hermes"
require() {
command -v "$1" >/dev/null 2>&1 || { echo "Error: '$1' not found" >&2; exit 1; }
}
main() {
require docker
echo "Pulling latest Hermes Agent image (using AMD64 emulation if needed)..."
docker pull --platform linux/amd64 "$HERMES_IMAGE"
echo ""
# Stop and remove existing container if it exists
if docker ps -a --format '{{.Names}}' | grep -q "^${HERMES_CONTAINER}$"; then
echo "Stopping existing Hermes container..."
docker stop "$HERMES_CONTAINER" >/dev/null 2>&1 || true
echo "Removing existing Hermes container..."
docker rm -f "$HERMES_CONTAINER" >/dev/null 2>&1 || true
fi
# Ensure data directory exists
if [[ ! -d "$HERMES_DATA_DIR" ]]; then
echo "Creating Hermes data directory: $HERMES_DATA_DIR"
mkdir -p "$HERMES_DATA_DIR"
fi
echo "Starting updated Hermes Agent container..."
docker run -d --platform linux/amd64 \
--name "$HERMES_CONTAINER" \
--restart unless-stopped \
--memory=4g \
--cpus=2 \
--shm-size=1g \
-v "$HERMES_DATA_DIR:/opt/data" \
"$HERMES_IMAGE" gateway run
echo ""
echo "Hermes Agent upgraded successfully!"
echo "Container: $HERMES_CONTAINER"
echo "Data directory: $HERMES_DATA_DIR"
echo ""
echo "Use 'hermes-logs' to view logs"
echo "Use 'hermes-status' to check status"
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment