#!/usr/bin/env bash
# forage-discover.sh — Start the Forage autonomous discovery agent
#
# Prerequisites:
#   - forage-server running at localhost:4242
#     cargo run -p forage-server --manifest-path applications/forage/server/Cargo.toml
#   - Claude Code CLI installed with --chrome support
#     https://code.claude.com/docs/en/chrome
#
# Usage:
#   ./forage-discover.sh

set -euo pipefail

AGENT_MD="$(dirname "$0")/applications/forage/agent.md"

if [[ ! -f "$AGENT_MD" ]]; then
  echo "Error: agent instructions not found at $AGENT_MD" >&2
  exit 1
fi

echo "Starting Forage discovery agent..."
echo "Server: http://localhost:4242"
echo "Agent instructions: $AGENT_MD"
echo ""
echo "Press Ctrl+C to stop."
echo ""

exec claude --chrome "$(cat "$AGENT_MD")"
