#!/bin/bash

# AI News Digest OpenClaw Skill Wrapper
# Usage: ./ai-news-digest.sh [options]

SKILL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
JULIA_SCRIPT="$SKILL_DIR/main.jl"

# Check if Julia is installed
if ! command -v julia &> /dev/null; then
    echo "❌ Error: Julia is not installed or not in PATH"
    echo "Please install Julia from https://julialang.org/downloads/"
    exit 1
fi

# Check if dependencies are installed
if [ ! -f "$SKILL_DIR/Manifest.toml" ]; then
    echo "🔧 Setting up dependencies..."
    cd "$SKILL_DIR"
    julia install.jl
fi

# Run the Julia script with all passed arguments
cd "$SKILL_DIR"
julia --project=. "$JULIA_SCRIPT" "$@"