#!/usr/bin/env bash

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"

WORKSPACE_ROOT="${DAILYSEEK_WORKSPACE_ROOT:-$PWD}"
CONFIG_PATH="${DAILYSEEK_CONFIG_PATH:-$PLUGIN_ROOT/config/workflow/dailyseek.json}"
REPOS_PATH="${DAILYSEEK_REPOS_PATH:-$PLUGIN_ROOT/config/workflow/repos.json}"

if ! command -v python3 >/dev/null 2>&1; then
  echo "Error: python3 is required." >&2
  exit 1
fi

if [ ! -f "$CONFIG_PATH" ]; then
  echo "Error: dailyseek config not found: $CONFIG_PATH" >&2
  exit 1
fi

if [ ! -f "$REPOS_PATH" ]; then
  echo "Error: repos config not found: $REPOS_PATH" >&2
  exit 1
fi

python3 "$SCRIPT_DIR/activity_report.py" \
  --workspace-root "$WORKSPACE_ROOT" \
  --config "$CONFIG_PATH" \
  --repos-config "$REPOS_PATH" \
  "$@"
