#!/usr/bin/env bash
set -euo pipefail

MOSAIC_HOME="${MOSAIC_HOME:-$HOME/.config/mosaic}"

consume="$MOSAIC_HOME/tools/_scripts/mosaic-orchestrator-matrix-consume"
run="$MOSAIC_HOME/tools/_scripts/mosaic-orchestrator-run"
publish="$MOSAIC_HOME/tools/_scripts/mosaic-orchestrator-matrix-publish"

for cmd in "$consume" "$run" "$publish"; do
  if [[ ! -x "$cmd" ]]; then
    echo "[mosaic-orch-cycle] missing executable: $cmd" >&2
    exit 1
  fi
done

"$consume"
"$run" --once "$@"
"$publish"
